]> git.saurik.com Git - wxWidgets.git/commitdiff
Set string in wxEVT_COMMAND_COMBOBOX_SELECTED event in wxOSX/Cocoa.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 2 Jul 2012 15:03:00 +0000 (15:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 2 Jul 2012 15:03:00 +0000 (15:03 +0000)
Pass the selected string and not only its index in the event generated when
combobox selection changes in wxOSX/Cocoa.

Closes #14383.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71941 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/widgets/combobox.cpp
src/osx/cocoa/combobox.mm

index f5ef0d5127bd1af6fe9fc27b9bc293774aeeddff..a36f3a008502e465a2def7b8c229e393081a8191 100644 (file)
@@ -672,6 +672,12 @@ void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event)
     wxLogMessage(wxT("Combobox item %ld selected"), sel);
 
     wxLogMessage(wxT("Combobox GetValue(): %s"), m_combobox->GetValue().c_str() );
+
+    if ( event.GetString() != m_combobox->GetValue() )
+    {
+        wxLogMessage("ERROR: Event has different string \"%s\"",
+                     event.GetString());
+    }
 }
 
 void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
index 379027674cce8e53bd3894c72b5229c36a2e29e5..f0d4ea667756b03182751eb3101524f955010859 100644 (file)
     wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
     if ( impl && impl->ShouldSendEvents())
     {
-        wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+        wxComboBox* wxpeer = static_cast<wxComboBox*>(impl->GetWXPeer());
         if ( wxpeer ) {
+            const int sel = wxpeer->GetSelection();
+
             wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, wxpeer->GetId());
             event.SetEventObject( wxpeer );
-            event.SetInt( static_cast<wxComboBox*>(wxpeer)->GetSelection() );
+            event.SetInt( sel );
+            event.SetString( wxpeer->GetString(sel) );
             // For some reason, wxComboBox::GetValue will not return the newly selected item 
             // while we're inside this callback, so use AddPendingEvent to make sure
             // GetValue() returns the right value.