From 3d77cd4d3c485e9ff430115a032aafcb286e9768 Mon Sep 17 00:00:00 2001 From: zeljko Date: Fri, 12 Mar 2010 15:13:57 +0000 Subject: [PATCH] Gtk2: fix for listbox itemindex. fixes #15784 git-svn-id: trunk@23966 - --- lcl/interfaces/gtk2/gtk2wsstdctrls.pp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp index f780d22044..71675b74a6 100644 --- a/lcl/interfaces/gtk2/gtk2wsstdctrls.pp +++ b/lcl/interfaces/gtk2/gtk2wsstdctrls.pp @@ -373,6 +373,7 @@ var Widget: PGtkWidget; Path: PGtkTreePath; Column: PGtkTreeViewColumn; + Selection: PGtkTreeSelection; begin Result := -1; if not WSCheckHandleAllocated(ACustomListBox, 'GetItemIndex') then @@ -381,9 +382,17 @@ begin if GtkWidgetIsA(Widget, gtk_tree_view_get_type) then begin gtk_tree_view_get_cursor(PGtkTreeView(Widget), Path, column); + if Path <> nil then - Result := gtk_tree_path_get_indices(Path)^ - else + begin + Result := gtk_tree_path_get_indices(Path)^; + if Result = 0 then + begin + Selection := gtk_tree_view_get_selection(PGtkTreeView(Widget)); + if not gtk_tree_selection_path_is_selected(Selection, Path) then + Result := -1; + end; + end else Result := -1; end; end;