X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e6e839336c9f9a869d40b3c7ed212e6f6641d04f..6d7b547184bfdcdf67790755deb0122050b1d728:/src/gtk/listbox.cpp?ds=sidebyside diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index f0fba8492d..beb8d7d336 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -22,9 +22,9 @@ #include "wx/utils.h" #include "wx/settings.h" #include "wx/checklst.h" + #include "wx/arrstr.h" #endif -#include "wx/arrstr.h" #include "wx/gtk/private.h" #include "wx/gtk/treeentry_gtk.h" @@ -944,7 +944,30 @@ bool wxListBox::IsSelected( int n ) const void wxListBox::DoSetSelection( int n, bool select ) { - return GtkSetSelection(n, select, true); //docs say no events here + // passing -1 to SetSelection() is documented to deselect all items + if ( n == wxNOT_FOUND ) + { + // ... and not generate any events in the process + GtkDeselectAll(); + } + + wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetSelection") ); + + // don't generate the selection event + GtkSetSelection(n, select, true); +} + +void wxListBox::GtkDeselectAll() +{ + wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") ); + + GtkTreeSelection* selection = gtk_tree_view_get_selection(m_treeview); + + m_blockEvent = true; + + gtk_tree_selection_unselect_all(selection); + + m_blockEvent = false; } void wxListBox::GtkSetSelection(int n, const bool select, const bool blockEvent)