TCustomListbox does not scroll to proper position in Cocoa
Original Reporter info from Mantis: maaartinus
-
Reporter name: Maaartin
Original Reporter info from Mantis: maaartinus
- Reporter name: Maaartin
Description:
Using gtk2, after setting the ItemIndex, the TCustomListbox scrolls to make the selected items visible (just like in Delphi).
Using either Carbon or Cocoa, this isn't the case. I guess, this is a bug, isn't it?
In Carbon (which I don't care about anymore), I could fix it by overriding like follows
PROCEDURE TMyComboListbox.SetItemIndex (AIndex: INTEGER);
VAR Low, High: INTEGER;
BEGIN
INHERITED;
Low := Max (0, AIndex - MyDropDownCount);
High := Min (Max (0, AIndex - 1), Items.Count-1);
IF TopIndex < Low THEN begin
TopIndex := Low;
end ELSE IF TopIndex > High THEN begin
TopIndex := High;
END;
END;
This does not work in Cocoa: With MyDropDownCount=11, AIndex=52, I get Low=41 and after setting TopIndex := Low, I get TopIndex=28. The listbox scrolls only about halfway to where it should.
Steps to reproduce:
Create a listbox with SetSubComponent (True);
Insert some 100 elements, where only 10 of them are visible.
Set ItemIndex=52 and TopIndex=41.
Observe TopIndex<>41 and the 52th element not being shown.
Mantis conversion info:
- Mantis ID: 35435
- Build: tags/lazarus_2_0_2
- Version: 2.0.2
- Fixed in revision: 61161 (#398156e2)