From 1ce63eab2e1c0772b4f584df5e6f0220a848f80b Mon Sep 17 00:00:00 2001 From: juha Date: Sun, 18 Oct 2015 22:28:43 +0000 Subject: [PATCH] LazControls: Use ItemIndex for moving up/down in ListFilterEdit. Issue #28779. git-svn-id: trunk@50116 - --- components/lazcontrols/listfilteredit.pas | 49 ++++++----------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/components/lazcontrols/listfilteredit.pas b/components/lazcontrols/listfilteredit.pas index 909c61ce8b..cf0681abc5 100644 --- a/components/lazcontrols/listfilteredit.pas +++ b/components/lazcontrols/listfilteredit.pas @@ -36,9 +36,7 @@ type fSortedData: TStringList; fCheckedItems: TStringMap; // Only needed for TCheckListBox function CompareFNs(AFilename1,AFilename2: string): integer; - function GetFirstSelected: Integer; procedure SetFilteredListbox(const AValue: TCustomListBox); - procedure UnselectAll; protected procedure MoveNext; override; procedure MovePrev; override; @@ -56,7 +54,6 @@ type public property SelectionList: TStringList read fSelectionList; property Items: TStringList read fOriginalData; - property Data: TStringList read fOriginalData; deprecated 'Use property Items instead'; published property FilteredListbox: TCustomListBox read fFilteredListbox write SetFilteredListbox; end; @@ -226,50 +223,28 @@ begin end; end; -function TListFilterEdit.GetFirstSelected: Integer; -var - i: Integer; -begin - Result := -1; - for i := 0 to fFilteredListbox.Count - 1 do - if fFilteredListbox.Selected[i] then - Exit(i); -end; - -procedure TListFilterEdit.UnselectAll; -var - i: Integer; -begin - for i := 0 to fFilteredListbox.Count - 1 do - fFilteredListbox.Selected[i] := False; -end; - procedure TListFilterEdit.MoveNext; var i: Integer; begin - i := GetFirstSelected + 1; - if fFilteredListbox.Count > 0 then begin - UnselectAll; - if i < fFilteredListbox.Count then - fFilteredListbox.Selected[i] := True - else - fFilteredListbox.Selected[0] := True; - end; + if fFilteredListbox.Count = 0 then Exit; + i := fFilteredListbox.ItemIndex + 1; + if i < fFilteredListbox.Count then + fFilteredListbox.ItemIndex := i + else + fFilteredListbox.ItemIndex := 0; end; procedure TListFilterEdit.MovePrev; var i: Integer; begin - i := GetFirstSelected - 1; - if fFilteredListbox.Count > 0 then begin - UnselectAll; - if i >= 0 then - fFilteredListbox.Selected[i] := True - else - fFilteredListbox.Selected[fFilteredListbox.Count-1] := True; - end; + if fFilteredListbox.Count = 0 then Exit; + i := fFilteredListbox.ItemIndex - 1; + if i >= 0 then + fFilteredListbox.ItemIndex := i + else + fFilteredListbox.ItemIndex := fFilteredListbox.Count-1; end; function TListFilterEdit.ReturnKeyHandled: Boolean;