Issue #1577: make apphelpers.SelectNode more intelligent, returning true/false to indicate whether it successful went through OnFocusChanging event

This commit is contained in:
Ansgar Becker
2022-05-05 19:13:42 +02:00
parent fe9bc11505
commit 56262e50a4
2 changed files with 26 additions and 21 deletions

View File

@ -367,7 +367,7 @@ var
rx: TRegExpr;
Prompt: TModalResult;
ReplaceFlags: TReplaceFlags;
FocusChangeAllowed: Boolean;
NodeSelected: Boolean;
begin
// Data grid version of DoSearchReplaceText
MainForm.ShowStatusMsg(_('Searching ...'));
@ -388,7 +388,7 @@ begin
ReplaceFlags := [rfReplaceAll];
if not (ssoMatchCase in Options) then
Include(ReplaceFlags, rfIgnoreCase);
FocusChangeAllowed := True;
NodeSelected := True;
// Init regular expression
rx := TRegExpr.Create;
@ -451,12 +451,9 @@ begin
Inc(MatchCount);
// Set focus on node and column
if (Node <> Grid.FocusedNode) and Assigned(Grid.OnFocusChanging) then begin
Grid.OnFocusChanging(Grid, Grid.FocusedNode, Node, Grid.FocusedColumn, Column, FocusChangeAllowed);
if not FocusChangeAllowed then
Break;
end;
SelectNode(Grid, Node, False);
NodeSelected := SelectNode(Grid, Node, False);
if not NodeSelected then
Break;
Grid.FocusedColumn := Column;
// Replace logic
@ -497,7 +494,7 @@ begin
if Match and (not (ssoReplaceAll in Options)) then
Break;
if not FocusChangeAllowed then
if not NodeSelected then
Break;
if Backwards then