Forgot client data

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2008-05-22 21:47:20 +00:00
parent e8c72fce14
commit 415ab72e8d

View File

@@ -112,6 +112,17 @@ gtk_listbox_row_activated_callback(GtkTreeView * WXUNUSED(treeview),
// "changed" // "changed"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void SendEvent( wxCommandEvent &event, wxListBox *listbox, int item )
{
event.SetInt( item );
event.SetString( listbox->GetString( item ) );
if ( listbox->HasClientObjectData() )
event.SetClientObject( listbox->GetClientObject(item) );
else if ( listbox->HasClientUntypedData() )
event.SetClientData( listbox->GetClientData(item) );
listbox->HandleWindowEvent( event );
}
extern "C" { extern "C" {
static void static void
gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection), gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
@@ -155,28 +166,21 @@ gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
{ {
// indicate that this is a deselection // indicate that this is a deselection
event.SetExtraLong( 0 ); event.SetExtraLong( 0 );
int item = listbox->m_oldSelection[0];
// take first item in old selection
event.SetInt( listbox->m_oldSelection[0] );
event.SetString( listbox->GetString( listbox->m_oldSelection[0] ) );
listbox->m_oldSelection = selections; listbox->m_oldSelection = selections;
SendEvent( event, listbox, item );
listbox->HandleWindowEvent( event );
return; return;
} }
int item;
// Now test if any new item is selected // Now test if any new item is selected
bool any_new_selected = false; bool any_new_selected = false;
size_t idx; size_t idx;
for (idx = 0; idx < selections.GetCount(); idx++) for (idx = 0; idx < selections.GetCount(); idx++)
{ {
int item = selections[idx]; item = selections[idx];
if (listbox->m_oldSelection.Index(item) == wxNOT_FOUND) if (listbox->m_oldSelection.Index(item) == wxNOT_FOUND)
{ {
event.SetInt( item );
event.SetString( listbox->GetString( item ) );
any_new_selected = true; any_new_selected = true;
break; break;
} }
@@ -186,9 +190,8 @@ gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
{ {
// indicate that this is a selection // indicate that this is a selection
event.SetExtraLong( 1 ); event.SetExtraLong( 1 );
listbox->m_oldSelection = selections; listbox->m_oldSelection = selections;
listbox->HandleWindowEvent( event ); SendEvent( event, listbox, item );
return; return;
} }
@@ -196,11 +199,9 @@ gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
bool any_new_deselected = false; bool any_new_deselected = false;
for (idx = 0; idx < listbox->m_oldSelection.GetCount(); idx++) for (idx = 0; idx < listbox->m_oldSelection.GetCount(); idx++)
{ {
int item = listbox->m_oldSelection[idx]; item = listbox->m_oldSelection[idx];
if (selections.Index(item) == wxNOT_FOUND) if (selections.Index(item) == wxNOT_FOUND)
{ {
event.SetInt( item );
event.SetString( listbox->GetString( item ) );
any_new_deselected = true; any_new_deselected = true;
break; break;
} }
@@ -210,9 +211,8 @@ gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
{ {
// indicate that this is a selection // indicate that this is a selection
event.SetExtraLong( 0 ); event.SetExtraLong( 0 );
listbox->m_oldSelection = selections; listbox->m_oldSelection = selections;
listbox->HandleWindowEvent( event ); SendEvent( event, listbox, item );
return; return;
} }