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:
Julian Smart
2007-08-10 10:37:28 +00:00
parent 4ac1930ee2
commit b4709ab2a7

View File

@@ -43,8 +43,6 @@
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Macro to tell which row the strings are in (1 if native checklist, 0 if not) // 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)) if (listbox->IsSelected(sel))
{ {
GtkTreeEntry* entry = listbox->GtkGetEntry(sel); GtkTreeEntry* entry = listbox->GtkGetEntry(sel);
if (entry) if (entry)
{ {
event.SetInt(sel); event.SetInt(sel);
@@ -93,7 +91,7 @@ gtk_listbox_row_activated_callback(GtkTreeView *treeview,
event.SetClientObject( (wxClientData*) gtk_tree_entry_get_userdata(entry) ); event.SetClientObject( (wxClientData*) gtk_tree_entry_get_userdata(entry) );
else if ( listbox->HasClientUntypedData() ) else if ( listbox->HasClientUntypedData() )
event.SetClientData( gtk_tree_entry_get_userdata(entry) ); event.SetClientData( gtk_tree_entry_get_userdata(entry) );
g_object_unref (entry); g_object_unref (entry);
} }
else else
@@ -148,9 +146,9 @@ static void
gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox ) gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
{ {
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
if (listbox->m_blockEvent) return; if (listbox->m_blockEvent) return;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
event.SetEventObject( listbox ); event.SetEventObject( listbox );
@@ -158,15 +156,15 @@ gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
{ {
wxArrayInt selections; wxArrayInt selections;
listbox->GetSelections( selections ); listbox->GetSelections( selections );
if (selections.GetCount() == 0) if (selections.GetCount() == 0)
{ {
// indicate that this is a deselection // indicate that this is a deselection
event.SetExtraLong( 0 ); event.SetExtraLong( 0 );
event.SetInt( -1 ); event.SetInt( -1 );
listbox->GetEventHandler()->ProcessEvent( event ); listbox->GetEventHandler()->ProcessEvent( event );
return; return;
} }
else else
@@ -174,7 +172,7 @@ gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
// indicate that this is a selection // indicate that this is a selection
event.SetExtraLong( 1 ); event.SetExtraLong( 1 );
event.SetInt( selections[0] ); event.SetInt( selections[0] );
listbox->GetEventHandler()->ProcessEvent( event ); listbox->GetEventHandler()->ProcessEvent( event );
} }
} }
@@ -186,9 +184,9 @@ gtk_listitem_changed_callback( GtkTreeSelection* selection, wxListBox *listbox )
// indicate that this is a deselection // indicate that this is a deselection
event.SetExtraLong( 0 ); event.SetExtraLong( 0 );
event.SetInt( -1 ); event.SetInt( -1 );
listbox->GetEventHandler()->ProcessEvent( event ); listbox->GetEventHandler()->ProcessEvent( event );
return; return;
} }
else else
@@ -406,7 +404,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
GtkTreeSelection* selection = gtk_tree_view_get_selection( m_treeview ); GtkTreeSelection* selection = gtk_tree_view_get_selection( m_treeview );
g_signal_connect_after (selection, "changed", g_signal_connect_after (selection, "changed",
G_CALLBACK (gtk_listitem_changed_callback), this); G_CALLBACK (gtk_listitem_changed_callback), this);
@@ -720,6 +718,9 @@ void wxListBox::SetString(unsigned int n, const wxString &string)
wxString label = 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 // 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 // doesn't resort or update when changed above and there is no real
// notification function... // notification function...
@@ -735,6 +736,8 @@ void wxListBox::SetString(unsigned int n, const wxString &string)
GtkInsertItems(aItems, &userdata, n); GtkInsertItems(aItems, &userdata, n);
if (bWasSelected) if (bWasSelected)
wxListBox::GtkSetSelection(n, true, true); wxListBox::GtkSetSelection(n, true, true);
m_blockEvent = false;
} }
wxString wxListBox::GetString(unsigned int n) const wxString wxListBox::GetString(unsigned int n) const