deselect all items when SetSelection(-1) is called (patch 1506943)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39836 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
be0ac1819a
commit
ef33382e43
@ -100,6 +100,7 @@ public:
|
|||||||
struct _GtkTreeEntry* GtkGetEntry(int pos) const;
|
struct _GtkTreeEntry* GtkGetEntry(int pos) const;
|
||||||
void GtkInsertItems(const wxArrayString& items,
|
void GtkInsertItems(const wxArrayString& items,
|
||||||
void** clientData, unsigned int pos);
|
void** clientData, unsigned int pos);
|
||||||
|
void GtkDeselectAll();
|
||||||
void GtkSetSelection(int n, const bool select, const bool blockEvent);
|
void GtkSetSelection(int n, const bool select, const bool blockEvent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -944,7 +944,30 @@ bool wxListBox::IsSelected( int n ) const
|
|||||||
|
|
||||||
void wxListBox::DoSetSelection( int n, bool select )
|
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)
|
void wxListBox::GtkSetSelection(int n, const bool select, const bool blockEvent)
|
||||||
|
Loading…
Reference in New Issue
Block a user