diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas index 740cfd6e..16026ceb 100644 --- a/source/grideditlinks.pas +++ b/source/grideditlinks.pas @@ -51,6 +51,7 @@ type // The right constructor, we need the Tree reference constructor Create(Tree: TVirtualStringTree; AllowEdit: Boolean); overload; virtual; destructor Destroy; override; + property Tree: TVirtualStringTree read FTree; function PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; stdcall; function BeginEdit: Boolean; virtual; stdcall; function CancelEdit: Boolean; virtual; stdcall; @@ -213,6 +214,8 @@ type end; +var + ActiveGridEditor: TBaseGridEditorLink; implementation @@ -249,6 +252,7 @@ begin SendMessage(FParentForm.Handle, WM_SETREDRAW, 0, 0); FModified := False; FAllowEdit := AllowEdit; + ActiveGridEditor := Self; end; destructor TBaseGridEditorLink.Destroy; @@ -258,6 +262,7 @@ var DoPrev: Boolean; begin inherited; + ActiveGridEditor := nil; if FLastKeyDown = VK_TAB then begin DoPrev := ssShift in FLastShiftState; // Advance to next/previous visible column/node. diff --git a/source/main.pas b/source/main.pas index 09d58930..4a882576 100644 --- a/source/main.pas +++ b/source/main.pas @@ -5618,13 +5618,14 @@ end; procedure TMainForm.PageControlMainChanging(Sender: TObject; var AllowChange: Boolean); -var - Grid: TVirtualStringTree; begin // Leave editing mode on tab changes so the editor does not stay somewhere - Grid := ActiveGrid; - if Assigned(Grid) and Grid.IsEditing then - Grid.CancelEditNode; + if Assigned(ActiveGridEditor) + and Assigned(ActiveGridEditor.Tree) + and ActiveGridEditor.Tree.IsEditing then begin + LogSQL('Cancelling tree edit mode on '+ActiveGridEditor.Tree.Name, lcDebug); + ActiveGridEditor.Tree.CancelEditNode; + end; end;