From eb8f6e0173d1c2938572cae9052f6a0d6a3b7156 Mon Sep 17 00:00:00 2001 From: Joost Nieuwenhuijse Date: Sun, 21 Feb 2016 19:55:46 +0100 Subject: [PATCH] Display the global menu bar if the last TLW is hidden in wxOSX Hiding the last TLW should be enough to show the global menu bar, but this only happened if it was closed and not just hidden. Closes #16201. --- include/wx/osx/frame.h | 1 + include/wx/osx/menu.h | 1 + src/osx/carbon/frame.cpp | 13 +++++++++++++ src/osx/menu_osx.cpp | 15 ++++++++++----- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/include/wx/osx/frame.h b/include/wx/osx/frame.h index 14bab22241..195145281f 100644 --- a/include/wx/osx/frame.h +++ b/include/wx/osx/frame.h @@ -51,6 +51,7 @@ public: virtual wxPoint GetClientAreaOrigin() const wxOVERRIDE; // override some more virtuals + virtual bool Show(bool show = true) wxOVERRIDE; virtual bool Enable(bool enable = true) wxOVERRIDE; // event handlers diff --git a/include/wx/osx/menu.h b/include/wx/osx/menu.h index 7772f93fc9..19886d2b66 100644 --- a/include/wx/osx/menu.h +++ b/include/wx/osx/menu.h @@ -152,6 +152,7 @@ public: static void SetAutoWindowMenu( bool enable ) { s_macAutoWindowMenu = enable ; } static bool GetAutoWindowMenu() { return s_macAutoWindowMenu ; } + void MacUninstallMenuBar() ; void MacInstallMenuBar() ; static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; } static void MacSetCommonMenuBar(wxMenuBar* menubar) { s_macCommonMenuBar=menubar; } diff --git a/src/osx/carbon/frame.cpp b/src/osx/carbon/frame.cpp index cc6a16f5ee..006a064142 100644 --- a/src/osx/carbon/frame.cpp +++ b/src/osx/carbon/frame.cpp @@ -412,4 +412,17 @@ void wxFrame::PositionBars() #endif } +bool wxFrame::Show(bool show) +{ + if ( !show ) + { +#if wxUSE_MENUS + if (m_frameMenuBar != NULL) + { + m_frameMenuBar->MacUninstallMenuBar(); + } +#endif + } + return wxFrameBase::Show(show); +} diff --git a/src/osx/menu_osx.cpp b/src/osx/menu_osx.cpp index 04f9c9da6e..0a7cee67b0 100644 --- a/src/osx/menu_osx.cpp +++ b/src/osx/menu_osx.cpp @@ -633,11 +633,7 @@ wxMenuBar::~wxMenuBar() if (s_macCommonMenuBar == this) s_macCommonMenuBar = NULL; - if (s_macInstalledMenuBar == this) - { - gs_emptyMenuBar->GetPeer()->MakeRoot(); - s_macInstalledMenuBar = NULL; - } + MacUninstallMenuBar(); wxDELETE( m_rootMenu ); // apple menu is a submenu, therefore we don't have to delete it m_appleMenu = NULL; @@ -652,6 +648,15 @@ void wxMenuBar::Refresh(bool WXUNUSED(eraseBackground), const wxRect *WXUNUSED(r wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") ); } +void wxMenuBar::MacUninstallMenuBar() +{ + if (s_macInstalledMenuBar == this) + { + gs_emptyMenuBar->GetPeer()->MakeRoot(); + s_macInstalledMenuBar = NULL; + } +} + void wxMenuBar::MacInstallMenuBar() { if ( s_macInstalledMenuBar == this )