Recent

Author Topic: [Solved] TTreeFilterEdit.OnFilterNode works bad  (Read 662 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2479
    • UVviewsoft
[Solved] TTreeFilterEdit.OnFilterNode works bad
« on: May 30, 2023, 09:34:33 am »
I added my handler, to allow filtering by N space-separated words in the filter field.
My handler:

Code: Pascal  [Select][+][-]
  1. function TfmMain.CodeTreeFilter_OnFilterNode(ItemNode: TTreeNode; out Done: Boolean): Boolean;
  2. var
  3.   SNodeText: string;
  4.   SItem: string;
  5.   Sep: TATStringSeparator;
  6. begin
  7.   SNodeText:= LowerCase(ItemNode.Text);
  8.   Sep.Init(CodeTreeFilter.FilterLowercase, ' ');
  9.   while Sep.GetItemStr(SItem) do
  10.   begin
  11.     if Pos(SItem, SNodeText)=0 then
  12.     begin
  13.       Done:= true;
  14.       exit(false);
  15.     end;
  16.   end;
  17.   Done:= true;
  18.   Result:= true;
  19. end;    
  20.  

when at least one space-separated word don't match, I return False and set Done=true. If all words are present - i return True and set Done=true. Is this OK logic?
But result is bad!

Lazarus 2.3.0 (rev main-2_3-3327-g27bf5d2ba7) FPC 3.2.3 x86_64-linux-gtk2

Maybe TreeFilterEdit event is buggy?
« Last Edit: May 30, 2023, 01:50:06 pm by AlexTP »

AlexTP

  • Hero Member
  • *****
  • Posts: 2479
    • UVviewsoft
Re: TTreeFilterEdit.OnFilterNode works bad
« Reply #1 on: May 30, 2023, 10:01:58 am »
I tried to not set Done to True. but again: filtering by n words don't work then (it filters only by 1st word). I am looking at the example of TreeFilterEdit which filters by space-separated words.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4541
  • I like bugs.
Re: TTreeFilterEdit.OnFilterNode works bad
« Reply #2 on: May 30, 2023, 10:39:25 am »
Lazarus 2.3.0 (rev main-2_3-3327-g27bf5d2ba7) FPC 3.2.3 x86_64-linux-gtk2
That is from 6 of May. Please update to latest revision.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

AlexTP

  • Hero Member
  • *****
  • Posts: 2479
    • UVviewsoft
Re: TTreeFilterEdit.OnFilterNode works bad
« Reply #3 on: May 30, 2023, 01:49:57 pm »
Updated, works now.

 

TinyPortal © 2005-2018