From ff8cb900da92489dd87712e409bfd4c1f5eacfb8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 7 Dec 2011 23:41:06 +0000 Subject: [PATCH] Implement wxComboBox::Popup() and Dismiss() for wxOSX/Cocoa. Unlike in the other ports, these methods currently don't generate any events under OS X because these events are never generated at all there. Closes #12642. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69948 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/osx/cocoa/private/textimpl.h | 3 +++ include/wx/osx/combobox.h | 2 ++ include/wx/osx/core/private.h | 2 ++ interface/wx/combobox.h | 12 +++++++----- src/osx/cocoa/combobox.mm | 12 ++++++++++++ src/osx/combobox_osx.cpp | 10 ++++++++++ 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 22627d5f5c..0d599a4541 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -509,6 +509,7 @@ OSX: for OS X 10.6. - Added wxApp::MacOpenFiles and deprecated wxApp::MacOpenFile. - Implement wxEVT_CHAR_HOOK event generation in wxOSX/Cocoa. +- Implemented wxComboBox::Popup() and Dismiss() in wxOSX/Cocoa (joostn). GTK: diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index f50d555ca2..9eb2c7328e 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -105,6 +105,9 @@ public : virtual wxString GetStringAtIndex(int pos) const; virtual int FindString(const wxString& text) const; + virtual void Popup(); + virtual void Dismiss(); + private: NSComboBox* m_comboBox; }; diff --git a/include/wx/osx/combobox.h b/include/wx/osx/combobox.h index e814474732..5d8e2f3b11 100644 --- a/include/wx/osx/combobox.h +++ b/include/wx/osx/combobox.h @@ -139,6 +139,8 @@ class WXDLLIMPEXP_CORE wxComboBox : virtual wxTextWidgetImpl* GetTextPeer() const; #endif // wxOSX_USE_CARBON + virtual void Popup(); + virtual void Dismiss(); // osx specific event handling common for all osx-ports diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 414f5e1cd6..95fee216ea 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -690,6 +690,8 @@ public : virtual void RemoveItem(int WXUNUSED(pos)) {} virtual void Clear() {} + virtual void Popup() {} + virtual void Dismiss() {} virtual wxString GetStringAtIndex(int WXUNUSED(pos)) const { return wxEmptyString; } diff --git a/interface/wx/combobox.h b/interface/wx/combobox.h index 738ca21a9d..71a9984d49 100644 --- a/interface/wx/combobox.h +++ b/interface/wx/combobox.h @@ -285,10 +285,11 @@ public: /** Shows the list box portion of the combo box. - Currently only implemented in wxMSW and wxGTK. + Currently this method is implemented in wxMSW, wxGTK and wxOSX/Cocoa. Notice that calling this function will generate a - @c wxEVT_COMMAND_COMBOBOX_DROPDOWN event. + @c wxEVT_COMMAND_COMBOBOX_DROPDOWN event except under wxOSX where + generation of this event is not supported at all. @since 2.9.1 */ @@ -297,15 +298,16 @@ public: /** Hides the list box portion of the combo box. - Currently only implemented in wxMSW and wxGTK. + Currently this method is implemented in wxMSW, wxGTK and wxOSX/Cocoa. Notice that calling this function will generate a - @c wxEVT_COMMAND_COMBOBOX_CLOSEUP event. + @c wxEVT_COMMAND_COMBOBOX_CLOSEUP event except under wxOSX where + generation of this event is not supported at all. @since 2.9.1 */ virtual void Dismiss(); - + virtual int GetSelection() const; virtual void GetSelection(long *from, long *to) const; virtual void SetSelection(int n); diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index 2745d17dec..69342bf7d1 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -165,6 +165,18 @@ int wxNSComboBoxControl::FindString(const wxString& text) const return result; } +void wxNSComboBoxControl::Popup() +{ + id ax = NSAccessibilityUnignoredDescendant(m_comboBox); + [ax accessibilitySetValue: [NSNumber numberWithBool: YES] forAttribute: NSAccessibilityExpandedAttribute]; +} + +void wxNSComboBoxControl::Dismiss() +{ + id ax = NSAccessibilityUnignoredDescendant(m_comboBox); + [ax accessibilitySetValue: [NSNumber numberWithBool: NO] forAttribute: NSAccessibilityExpandedAttribute]; +} + wxWidgetImplType* wxWidgetImpl::CreateComboBox( wxComboBox* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), diff --git a/src/osx/combobox_osx.cpp b/src/osx/combobox_osx.cpp index fe9f812f75..3dc89288ee 100644 --- a/src/osx/combobox_osx.cpp +++ b/src/osx/combobox_osx.cpp @@ -215,4 +215,14 @@ wxComboWidgetImpl* wxComboBox::GetComboPeer() const return dynamic_cast (GetPeer()); } +void wxComboBox::Popup() +{ + GetComboPeer()->Popup(); +} + +void wxComboBox::Dismiss() +{ + GetComboPeer()->Dismiss(); +} + #endif // wxUSE_COMBOBOX && wxOSX_USE_COCOA -- 2.45.2