From 0d8653db6a382f00691564e7ce16cf7fc12cd71c Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 17 Jan 2010 10:50:47 +0000 Subject: [PATCH] Override VirtualTree's incremental search event, make it case insensitive, and apply that event in FixVT to various lists and grids, which have IncrementalSearch enabled. Fixes issue #1605. --- source/grideditlinks.pas | 1 + source/helpers.pas | 3 +++ source/main.pas | 17 +++++++++++++++++ source/table_editor.dfm | 1 + 4 files changed, 22 insertions(+) diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas index fdfadd0b..fb6c5f97 100644 --- a/source/grideditlinks.pas +++ b/source/grideditlinks.pas @@ -1240,6 +1240,7 @@ begin FTreeSelect.OnHotChange := DoTreeSelectHotChange; FTreeSelect.OnPaintText := DoTreeSelectPaintText; FTreeSelect.OnExit := DoEndEdit; + FixVT(FTreeSelect); FMainControl := FTreeSelect; FMemoHelp := TMemo.Create(FParentForm); diff --git a/source/helpers.pas b/source/helpers.pas index f485efa0..0dd427a6 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -2515,6 +2515,9 @@ begin VT.OnGetHint := MainForm.vstGetHint; VT.ShowHint := True; VT.HintMode := hmToolTip; + // Apply case insensitive incremental search event + if VT.IncrementalSearch <> isNone then + VT.OnIncrementalSearch := Mainform.vstIncrementalSearch; end; diff --git a/source/main.pas b/source/main.pas index 5bf24436..613f40fe 100644 --- a/source/main.pas +++ b/source/main.pas @@ -613,6 +613,8 @@ type PVirtualNode; Column: TColumnIndex; var Result: Integer); procedure vstHeaderDraggedOut(Sender: TVTHeader; Column: TColumnIndex; DropPosition: TPoint); + procedure vstIncrementalSearch(Sender: TBaseVirtualTree; Node: PVirtualNode; const SearchText: String; + var Result: Integer); procedure DBtreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex); procedure DBtreeDblClick(Sender: TObject); @@ -5648,6 +5650,21 @@ begin end; +procedure TMainForm.vstIncrementalSearch(Sender: TBaseVirtualTree; Node: PVirtualNode; + const SearchText: String; var Result: Integer); +var + CellText: String; + VT: TVirtualStringTree; +begin + // Override VT's default incremental search behaviour. Make it case insensitive. + VT := Sender as TVirtualStringTree; + if VT.FocusedColumn = NoColumn then + Exit; + CellText := VT.Text[Node, VT.FocusedColumn]; + Result := StrLIComp(PChar(CellText), PChar(SearchText), Length(SearchText)); +end; + + {** A cell in ListCommandStats gets painted. Draw a progress bar on it to visualize its percentage value. diff --git a/source/table_editor.dfm b/source/table_editor.dfm index e57d7d43..94aa1930 100644 --- a/source/table_editor.dfm +++ b/source/table_editor.dfm @@ -75,6 +75,7 @@ object frmTableEditor: TfrmTableEditor Header.Font.Style = [] Header.Options = [hoColumnResize, hoDblClickResize, hoDrag, hoVisible] Images = MainForm.PngImageListMain + IncrementalSearch = isAll PopupMenu = popupColumns TabOrder = 2 TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoTristateTracking]