From 6d34b1b7606a3be587016cba38f618c67417771d Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Tue, 4 Feb 2014 09:32:16 +0000 Subject: [PATCH] Added support for wxEVT_COMBOBOX_DROPDOWN and wxEVT_COMBOBOX_CLOSEUP events to wxOSX/Cocoa. See #15762. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75783 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 5 +++++ interface/wx/combobox.h | 8 ++++---- src/osx/cocoa/combobox.mm | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6a938dcf82..5874f7b657 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -41,3 +41,8 @@ wxMSW: - Make wxFILTER_INCLUDE_LIST in wxTextValidator actually usable. - Fix handling of selected images in wxBitmapButton (Artur Wieczorek). - Support multiline strings in wxDC::DrawRotatedText() (Artur Wieczorek). + +wxOSX/Cocoa: + +- Add support for wxEVT_COMBOBOX_DROPDOWN and wxEVT_COMBOBOX_CLOSEUP + events (Igor Korot). diff --git a/interface/wx/combobox.h b/interface/wx/combobox.h index d3e75c84ab..a23358d2a8 100644 --- a/interface/wx/combobox.h +++ b/interface/wx/combobox.h @@ -60,14 +60,14 @@ @event{EVT_COMBOBOX_DROPDOWN(id, func)} Process a @c wxEVT_COMBOBOX_DROPDOWN event, which is generated when the list box part of the combo box is shown (drops down). - Notice that this event is currently only supported by wxMSW and - wxGTK with GTK+ 2.10 or later. + Notice that this event is only supported by wxMSW, wxGTK with GTK+ + 2.10 or later, and wxOSX/Cocoa. @event{EVT_COMBOBOX_CLOSEUP(id, func)} Process a @c wxEVT_COMBOBOX_CLOSEUP event, which is generated when the list box of the combo box disappears (closes up). This event is only generated for the same platforms as - @c wxEVT_COMBOBOX_DROPDOWN above. Also note that only wxMSW - supports adding or deleting items in this event. + @c wxEVT_COMBOBOX_DROPDOWN above. Also note that only wxMSW and + wxOSX/Cocoa support adding or deleting items in this event. @endEventTable @library{wxcore} diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index 112b37b43e..37e9c5d9fe 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -90,6 +90,38 @@ } } +- (void)comboBoxWillPopUp:(NSNotification *)notification +{ + wxUnusedVar(notification); + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + if( impl && impl->ShouldSendEvents() ) + { + wxComboBox* wxpeer = static_cast(impl->GetWXPeer()); + if( wxpeer ) + { + wxCommandEvent event(wxEVT_COMBOBOX_DROPDOWN, wxpeer->GetId()); + event.SetEventObject( wxpeer ); + wxpeer->GetEventHandler()->ProcessEvent( event ); + } + } +} + +- (void)comboBoxWillDismiss:(NSNotification *)notification +{ + wxUnusedVar(notification); + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + if( impl && impl->ShouldSendEvents() ) + { + wxComboBox* wxpeer = static_cast(impl->GetWXPeer()); + if( wxpeer ) + { + wxCommandEvent event(wxEVT_COMBOBOX_CLOSEUP, wxpeer->GetId()); + event.SetEventObject( wxpeer ); + wxpeer->GetEventHandler()->ProcessEvent( event ); + } + } +} + - (void)comboBoxSelectionDidChange:(NSNotification *)notification { wxUnusedVar(notification);