]> git.saurik.com Git - wxWidgets.git/commitdiff
Forgot client data
authorRobert Roebling <robert@roebling.de>
Thu, 22 May 2008 21:47:20 +0000 (21:47 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 22 May 2008 21:47:20 +0000 (21:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/listbox.cpp

index 7fbd69425fe03cb4b0d345d4c0d611ae5cac5859..66669dfdc21d8bed9a6f76bfbfaaf9c7f363c6e8 100644 (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" {
 static void
 gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
 extern "C" {
 static void
 gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
@@ -155,28 +166,21 @@ gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
         {
             // indicate that this is a deselection
             event.SetExtraLong( 0 );
         {
             // indicate that this is a deselection
             event.SetExtraLong( 0 );
-            
-            // take first item in old selection
-            event.SetInt( listbox->m_oldSelection[0] );
-            event.SetString( listbox->GetString( listbox->m_oldSelection[0] ) );
-            
+            int item = listbox->m_oldSelection[0];
             listbox->m_oldSelection = selections;
             listbox->m_oldSelection = selections;
-
-            listbox->HandleWindowEvent( event );
-
+            SendEvent( event, listbox, item );
             return;
         }
         
             return;
         }
         
+        int item;
         // Now test if any new item is selected
         bool any_new_selected = false;
         size_t idx;
         for (idx = 0; idx < selections.GetCount(); idx++)
         {
         // Now test if any new item is selected
         bool any_new_selected = false;
         size_t 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;
                 break;
             }
                 any_new_selected = true;
                 break;
             }
@@ -186,9 +190,8 @@ gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
         {
             // indicate that this is a selection
             event.SetExtraLong( 1 );
         {
             // indicate that this is a selection
             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;
         for (idx = 0; idx < listbox->m_oldSelection.GetCount(); idx++)
         {
         bool any_new_deselected = false;
         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;
                 break;
             }
                 any_new_deselected = true;
                 break;
             }
@@ -210,9 +211,8 @@ gtk_listitem_changed_callback(GtkTreeSelection * WXUNUSED(selection),
         {
             // indicate that this is a selection
             event.SetExtraLong( 0 );
         {
             // indicate that this is a selection
             event.SetExtraLong( 0 );
-
             listbox->m_oldSelection = selections;
             listbox->m_oldSelection = selections;
-            listbox->HandleWindowEvent( event );
+            SendEvent( event, listbox, item );
             return;
         }
         
             return;
         }