diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index f5ef0d5127..a36f3a0085 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -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)) diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index 379027674c..f0d4ea6677 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -76,11 +76,14 @@ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); if ( impl && impl->ShouldSendEvents()) { - wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); + wxComboBox* wxpeer = static_cast(impl->GetWXPeer()); if ( wxpeer ) { + const int sel = wxpeer->GetSelection(); + wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, wxpeer->GetId()); event.SetEventObject( wxpeer ); - event.SetInt( static_cast(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.