]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/combobox.cpp
Committed forgotten files
[wxWidgets.git] / src / gtk1 / combobox.cpp
index 9e6870a9d03b57a0f32828d32c72e4634344daf0..517993327f502e7a4c842a1057dfb43738de4247 100644 (file)
@@ -75,8 +75,16 @@ gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
 {
     // when the popup is hidden, throw a SELECTED event only if the combobox
     // selection changed.
 {
     // when the popup is hidden, throw a SELECTED event only if the combobox
     // selection changed.
-    int curSelection = combo->GetCurrentSelection();
-    if (g_SelectionBeforePopup != curSelection)
+    const int curSelection = combo->GetCurrentSelection();
+
+    const bool hasChanged = curSelection != g_SelectionBeforePopup;
+
+    // reset the selection flag to value meaning that it is hidden and do it
+    // now, before generating the events, so that GetSelection() returns the
+    // new value from the event handler
+    g_SelectionBeforePopup = wxID_NONE;
+
+    if ( hasChanged )
     {
         wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
         event.SetInt( curSelection );
     {
         wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
         event.SetInt( curSelection );
@@ -90,9 +98,6 @@ gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
         event2.SetEventObject( combo );
         combo->GetEventHandler()->ProcessEvent( event2 );
     }
         event2.SetEventObject( combo );
         combo->GetEventHandler()->ProcessEvent( event2 );
     }
-
-    // reset the selection flag to value meaning that it is hidden
-    g_SelectionBeforePopup = wxID_NONE;
 }
 }
 
 }
 }
 
@@ -223,7 +228,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
     // Disable GTK's broken events ...
     gtk_signal_disconnect( GTK_OBJECT(combo->entry), combo->entry_change_id );
 
     // Disable GTK's broken events ...
     gtk_signal_disconnect( GTK_OBJECT(combo->entry), combo->entry_change_id );
-    // ... and add surogate handler.
+    // ... and add surrogate handler.
     combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed",
                   (GtkSignalFunc) gtk_dummy_callback, combo);
 
     combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed",
                   (GtkSignalFunc) gtk_dummy_callback, combo);