mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 08:56:01 +02:00
LazControls: Use ItemIndex for moving up/down in ListFilterEdit. Issue #28779.
git-svn-id: trunk@50116 -
This commit is contained in:
parent
3b84c9a585
commit
1ce63eab2e
@ -36,9 +36,7 @@ type
|
|||||||
fSortedData: TStringList;
|
fSortedData: TStringList;
|
||||||
fCheckedItems: TStringMap; // Only needed for TCheckListBox
|
fCheckedItems: TStringMap; // Only needed for TCheckListBox
|
||||||
function CompareFNs(AFilename1,AFilename2: string): integer;
|
function CompareFNs(AFilename1,AFilename2: string): integer;
|
||||||
function GetFirstSelected: Integer;
|
|
||||||
procedure SetFilteredListbox(const AValue: TCustomListBox);
|
procedure SetFilteredListbox(const AValue: TCustomListBox);
|
||||||
procedure UnselectAll;
|
|
||||||
protected
|
protected
|
||||||
procedure MoveNext; override;
|
procedure MoveNext; override;
|
||||||
procedure MovePrev; override;
|
procedure MovePrev; override;
|
||||||
@ -56,7 +54,6 @@ type
|
|||||||
public
|
public
|
||||||
property SelectionList: TStringList read fSelectionList;
|
property SelectionList: TStringList read fSelectionList;
|
||||||
property Items: TStringList read fOriginalData;
|
property Items: TStringList read fOriginalData;
|
||||||
property Data: TStringList read fOriginalData; deprecated 'Use property Items instead';
|
|
||||||
published
|
published
|
||||||
property FilteredListbox: TCustomListBox read fFilteredListbox write SetFilteredListbox;
|
property FilteredListbox: TCustomListBox read fFilteredListbox write SetFilteredListbox;
|
||||||
end;
|
end;
|
||||||
@ -226,50 +223,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
procedure TListFilterEdit.MoveNext;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
i := GetFirstSelected + 1;
|
if fFilteredListbox.Count = 0 then Exit;
|
||||||
if fFilteredListbox.Count > 0 then begin
|
i := fFilteredListbox.ItemIndex + 1;
|
||||||
UnselectAll;
|
|
||||||
if i < fFilteredListbox.Count then
|
if i < fFilteredListbox.Count then
|
||||||
fFilteredListbox.Selected[i] := True
|
fFilteredListbox.ItemIndex := i
|
||||||
else
|
else
|
||||||
fFilteredListbox.Selected[0] := True;
|
fFilteredListbox.ItemIndex := 0;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TListFilterEdit.MovePrev;
|
procedure TListFilterEdit.MovePrev;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
i := GetFirstSelected - 1;
|
if fFilteredListbox.Count = 0 then Exit;
|
||||||
if fFilteredListbox.Count > 0 then begin
|
i := fFilteredListbox.ItemIndex - 1;
|
||||||
UnselectAll;
|
|
||||||
if i >= 0 then
|
if i >= 0 then
|
||||||
fFilteredListbox.Selected[i] := True
|
fFilteredListbox.ItemIndex := i
|
||||||
else
|
else
|
||||||
fFilteredListbox.Selected[fFilteredListbox.Count-1] := True;
|
fFilteredListbox.ItemIndex := fFilteredListbox.Count-1;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TListFilterEdit.ReturnKeyHandled: Boolean;
|
function TListFilterEdit.ReturnKeyHandled: Boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user