For consistency with other ports, don't generate a selection event
when we change a listbox item's label git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48001 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,8 +43,6 @@
|
||||
extern bool g_blockEventsOnDrag;
|
||||
extern bool g_blockEventsOnScroll;
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Macro to tell which row the strings are in (1 if native checklist, 0 if not)
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -83,7 +81,7 @@ gtk_listbox_row_activated_callback(GtkTreeView *treeview,
|
||||
if (listbox->IsSelected(sel))
|
||||
{
|
||||
GtkTreeEntry* entry = listbox->GtkGetEntry(sel);
|
||||
|
||||
|
||||
if (entry)
|
||||
{
|
||||
event.SetInt(sel);
|
||||
@@ -93,7 +91,7 @@ gtk_listbox_row_activated_callback(GtkTreeView *treeview,
|
||||
event.SetClientObject( (wxClientData*) gtk_tree_entry_get_userdata(entry) );
|
||||
else if ( listbox->HasClientUntypedData() )
|
||||
event.SetClientData( gtk_tree_entry_get_userdata(entry) );
|
||||
|
||||
|
||||
g_object_unref (entry);
|
||||
}
|
||||
else
|
||||
@@ -148,9 +146,9 @@ static void
|
||||
gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
|
||||
{
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
||||
|
||||
if (listbox->m_blockEvent) return;
|
||||
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
|
||||
event.SetEventObject( listbox );
|
||||
|
||||
@@ -158,15 +156,15 @@ gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
|
||||
{
|
||||
wxArrayInt selections;
|
||||
listbox->GetSelections( selections );
|
||||
|
||||
|
||||
if (selections.GetCount() == 0)
|
||||
{
|
||||
// indicate that this is a deselection
|
||||
event.SetExtraLong( 0 );
|
||||
event.SetInt( -1 );
|
||||
|
||||
|
||||
listbox->GetEventHandler()->ProcessEvent( event );
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -174,7 +172,7 @@ gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
|
||||
// indicate that this is a selection
|
||||
event.SetExtraLong( 1 );
|
||||
event.SetInt( selections[0] );
|
||||
|
||||
|
||||
listbox->GetEventHandler()->ProcessEvent( event );
|
||||
}
|
||||
}
|
||||
@@ -186,9 +184,9 @@ gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
|
||||
// indicate that this is a deselection
|
||||
event.SetExtraLong( 0 );
|
||||
event.SetInt( -1 );
|
||||
|
||||
|
||||
listbox->GetEventHandler()->ProcessEvent( event );
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -406,7 +404,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
|
||||
GtkTreeSelection* selection = gtk_tree_view_get_selection( m_treeview );
|
||||
|
||||
|
||||
g_signal_connect_after (selection, "changed",
|
||||
G_CALLBACK (gtk_listitem_changed_callback), this);
|
||||
|
||||
@@ -720,6 +718,9 @@ void wxListBox::SetString(unsigned int n, const wxString &string)
|
||||
|
||||
wxString label = string;
|
||||
|
||||
// Don't call the selection event handler if we only changed the item label
|
||||
m_blockEvent = true;
|
||||
|
||||
// RN: This may look wierd but the problem is that the TreeView
|
||||
// doesn't resort or update when changed above and there is no real
|
||||
// notification function...
|
||||
@@ -735,6 +736,8 @@ void wxListBox::SetString(unsigned int n, const wxString &string)
|
||||
GtkInsertItems(aItems, &userdata, n);
|
||||
if (bWasSelected)
|
||||
wxListBox::GtkSetSelection(n, true, true);
|
||||
|
||||
m_blockEvent = false;
|
||||
}
|
||||
|
||||
wxString wxListBox::GetString(unsigned int n) const
|
||||
|
Reference in New Issue
Block a user