From 947a8734acf3a9a1e3b5787ecf0d10f49fb0a18f Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 20 Dec 2013 16:03:13 +0000 Subject: [PATCH] reverting r74098, applying John's version, see #15008, #15765, #13841 will be backported if no regressions are discovered git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75401 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/popupwin.h | 2 ++ src/common/combocmn.cpp | 29 ++++++++++++++++++++++------- src/osx/carbon/popupwin.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/include/wx/osx/popupwin.h b/include/wx/osx/popupwin.h index ac42cd64dd..01a3a147db 100644 --- a/include/wx/osx/popupwin.h +++ b/include/wx/osx/popupwin.h @@ -26,6 +26,8 @@ public: bool Create(wxWindow *parent, int flags = wxBORDER_NONE); + virtual bool Show(bool show = true); + DECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow) }; diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index 82d1657960..edf10fe891 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -2070,19 +2070,16 @@ void wxComboCtrlBase::OnCharEvent(wxKeyEvent& event) void wxComboCtrlBase::OnFocusEvent( wxFocusEvent& event ) { - // On Mac, setting focus here leads to infinite recursion and eventually - // a crash due to the SetFocus call producing another event. - // Handle Mac in OnIdleEvent using m_resetFocus. + // On Mac, setting focus here led to infinite recursion so + // m_resetFocus is used as a guard if ( event.GetEventType() == wxEVT_SET_FOCUS ) { - if ( GetTextCtrl() && !GetTextCtrl()->HasFocus() ) + if ( !m_resetFocus && GetTextCtrl() && !GetTextCtrl()->HasFocus() ) { -#ifdef __WXMAC__ m_resetFocus = true; -#else GetTextCtrl()->SetFocus(); -#endif + m_resetFocus = false; } } @@ -2438,10 +2435,28 @@ void wxComboCtrlBase::ShowPopup() } } + +#ifdef __WXMAC__ +bool wxComboCtrlBase::AnimateShow( const wxRect& rect, int WXUNUSED(flags) ) +{ + // Overridden AnimateShow() will call Raise() and ShowWithEffect() so do + // here to avoid duplication. Raise and Show are needed for some contained + // control's scrollbars, selection highlights, hit-test accuracy and popup + // close via left mousedown when the mouse is not over the parent app. + if ( GetPopupWindow() ) + { + GetPopupWindow()->SetSize(rect); + GetPopupWindow()->Raise(); + GetPopupWindow()->Show(); + } + return true; +} +#else bool wxComboCtrlBase::AnimateShow( const wxRect& WXUNUSED(rect), int WXUNUSED(flags) ) { return true; } +#endif void wxComboCtrlBase::DoShowPopup( const wxRect& rect, int WXUNUSED(flags) ) { diff --git a/src/osx/carbon/popupwin.cpp b/src/osx/carbon/popupwin.cpp index d13810f1c0..65614cae2d 100644 --- a/src/osx/carbon/popupwin.cpp +++ b/src/osx/carbon/popupwin.cpp @@ -55,4 +55,28 @@ bool wxPopupWindow::Create(wxWindow *parent, int flags) } +// under + +bool wxPopupWindow::Show(bool show) +{ + if ( !wxWindow::Show(show) ) + return false; + + if ( m_nowpeer && show) + m_nowpeer->ShowWithoutActivating(); + else if ( m_nowpeer ) + m_nowpeer->Show(false); + + if ( show ) + { + // because apps expect a size event to occur at this moment + wxSizeEvent event(GetSize() , m_windowId); + event.SetEventObject(this); + HandleWindowEvent(event); + } + + return true; +} + + #endif // #if wxUSE_POPUPWIN