mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-21 09:39:31 +02:00
IDE: Fix moving up/down in ListFilterEdit. Also don't use Listbox.ItemHeight when = 0. Issue #29385.
git-svn-id: trunk@51267 -
This commit is contained in:
parent
a9f558b56b
commit
dfc8958222
@ -265,32 +265,6 @@ begin
|
||||
MoveTo(i, ASelect);
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.MovePageDown(ASelect: Boolean);
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
if fFilteredListbox.Items.Count = 0 then
|
||||
Exit;
|
||||
I := fFilteredListbox.ItemIndex + Pred(fFilteredListbox.ClientHeight div fFilteredListbox.ItemHeight);
|
||||
if (I < 0) or (I >= fFilteredListbox.Items.Count) then
|
||||
I := fFilteredListbox.Items.Count-1;
|
||||
|
||||
MoveTo(I, ASelect);
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.MovePageUp(ASelect: Boolean);
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
if fFilteredListbox.Items.Count = 0 then
|
||||
Exit;
|
||||
I := fFilteredListbox.ItemIndex - Pred(fFilteredListbox.ClientHeight div fFilteredListbox.ItemHeight);
|
||||
if (I < 0) or (I >= fFilteredListbox.Items.Count) then
|
||||
I := 0;
|
||||
|
||||
MoveTo(I, ASelect);
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.MovePrev(ASelect: Boolean);
|
||||
var
|
||||
i: Integer;
|
||||
@ -302,9 +276,39 @@ begin
|
||||
MoveTo(i, ASelect);
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.MovePageDown(ASelect: Boolean);
|
||||
var
|
||||
i, ih: Integer;
|
||||
begin
|
||||
if fFilteredListbox.Items.Count = 0 then
|
||||
Exit;
|
||||
ih := fFilteredListbox.ItemHeight;
|
||||
if ih = 0 then //fFilteredListbox.ItemHeight is always zero. Why?
|
||||
ih := 22;
|
||||
i := fFilteredListbox.ItemIndex + Pred(fFilteredListbox.ClientHeight div ih);
|
||||
if (i < 0) or (i >= fFilteredListbox.Items.Count) then
|
||||
i := fFilteredListbox.Items.Count-1;
|
||||
MoveTo(i, ASelect);
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.MovePageUp(ASelect: Boolean);
|
||||
var
|
||||
i, ih: Integer;
|
||||
begin
|
||||
if fFilteredListbox.Items.Count = 0 then
|
||||
Exit;
|
||||
ih := fFilteredListbox.ItemHeight;
|
||||
if ih = 0 then
|
||||
ih := 22;
|
||||
i := fFilteredListbox.ItemIndex - Pred(fFilteredListbox.ClientHeight div ih);
|
||||
if (i < 0) or (i >= fFilteredListbox.Items.Count) then
|
||||
i := 0;
|
||||
MoveTo(i, ASelect);
|
||||
end;
|
||||
|
||||
procedure TListFilterEdit.MoveTo(AIndex: Integer; ASelect: Boolean);
|
||||
var
|
||||
I, xOldItemIndex, xSelStart, xSelEnd: Integer;
|
||||
i, xOldItemIndex, xSelStart, xSelEnd: Integer;
|
||||
begin
|
||||
fFilteredListbox.LockSelectionChange;
|
||||
fFilteredListbox.Items.BeginUpdate;
|
||||
@ -319,23 +323,26 @@ begin
|
||||
while (xSelEnd<fFilteredListbox.Count) and fFilteredListbox.Selected[xSelEnd] do
|
||||
Inc(xSelEnd);
|
||||
fFilteredListbox.ItemIndex := AIndex;
|
||||
for I := Min(AIndex+1, xSelStart+1) to Max(AIndex-1, xSelEnd-1) do
|
||||
fFilteredListbox.Selected[I] := True;
|
||||
//Win32 sets ItemIndex to the last Selected[?] := True - in contrast to Gtk2 -> set selected again to work on all widgetsets
|
||||
fFilteredListbox.Selected[AIndex] := True;
|
||||
for i := Min(AIndex+1, xSelStart+1) to Max(AIndex-1, xSelEnd-1) do
|
||||
fFilteredListbox.Selected[i] := True;
|
||||
end else
|
||||
begin
|
||||
{$IFDEF LCLQt}
|
||||
// With LCL-Qt setting the ItemIndex does not clear selection.
|
||||
for i := 0 to fFilteredListbox.Count - 1 do
|
||||
fFilteredListbox.Selected[i] := False;
|
||||
{$ENDIF LCLQt}
|
||||
fFilteredListbox.ItemIndex := AIndex;
|
||||
fFilteredListbox.Selected[AIndex] := True;
|
||||
end;
|
||||
|
||||
if not fFilteredListbox.ItemFullyVisible(AIndex) then
|
||||
Assert(fFilteredListbox.ItemFullyVisible(AIndex), 'TListFilterEdit.MoveTo: Item not fully visible');
|
||||
{ if not fFilteredListbox.ItemFullyVisible(AIndex) then
|
||||
begin
|
||||
if fFilteredListbox.TopIndex < AIndex then
|
||||
fFilteredListbox.TopIndex := AIndex - Pred(fFilteredListbox.ClientHeight div fFilteredListbox.ItemHeight)
|
||||
else
|
||||
fFilteredListbox.TopIndex := AIndex;
|
||||
end;
|
||||
}
|
||||
finally
|
||||
fFilteredListbox.UnlockSelectionChange;
|
||||
fFilteredListbox.Items.EndUpdate;
|
||||
|
Loading…
Reference in New Issue
Block a user