From 5b715315822d295de585c5c229d56ffbde4f2fea Mon Sep 17 00:00:00 2001 From: zeljko Date: Sun, 11 Jan 2015 09:43:43 +0000 Subject: [PATCH] Gtk2: fixed TListBox with ItemIndex = -1 in lfm. issue #27276 git-svn-id: trunk@47330 - --- lcl/interfaces/gtk2/gtk2wsstdctrls.pp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp index 0dc03f3350..64443ef881 100644 --- a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp +++ b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp @@ -175,6 +175,7 @@ type class procedure SetSorted(const {%H-}ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override; class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override; class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; + class procedure ShowHide(const AWinControl: TWinControl); override; end; { TGtk2WSListBox } @@ -683,6 +684,15 @@ begin Gtk2WidgetSet.SetWidgetFont(Widget, AFont); end; +class procedure TGtk2WSCustomListBox.ShowHide(const AWinControl: TWinControl); +begin + // issue #27276 + if AWinControl.HandleAllocated and AWinControl.HandleObjectShouldBeVisible and + (TCustomListBox(AWinControl).ItemIndex = -1) then + SetItemIndex(TCustomListBox(AWinControl), TCustomListBox(AWinControl).ItemIndex); + inherited ShowHide(AWinControl); +end; + function gtk2ListBoxSelectionChangedAfter({%H-}Widget: PGtkWidget; WidgetInfo: PWidgetInfo): gboolean; cdecl; var