From 4f1b95ea5291c6b690caa0a82d4c4a8c598c148a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Sep 2010 19:36:37 +0000 Subject: [PATCH] Allow setting Mac-specific menu item ids to wxID_NONE to suppress them. If s_macAboutMenuItemId or s_macPreferencesMenuItemId was explicitly set to wxID_NONE by the application, don't add them to the standard menu at all, otherwise they would be present there but be always disabled and useless. This is still not documented because we really need a better API for this but it at least provides a temporary workaround for having useless menu items under OS X. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65560 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/menu_osx.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/osx/menu_osx.cpp b/src/osx/menu_osx.cpp index e251fa461d..4ee92302bd 100644 --- a/src/osx/menu_osx.cpp +++ b/src/osx/menu_osx.cpp @@ -515,13 +515,26 @@ void wxMenuBar::Init() m_appleMenu = new wxMenu(); m_appleMenu->SetAllowRearrange(false); - m_appleMenu->Append( wxApp::s_macAboutMenuItemId, "About..." ); - m_appleMenu->AppendSeparator(); + + // Create standard items unless the application explicitly disabled this by + // setting the corresponding ids to wxID_NONE: although this is not + // recommended, sometimes these items really don't make sense. + if ( wxApp::s_macAboutMenuItemId != wxID_NONE ) + { + m_appleMenu->Append( wxApp::s_macAboutMenuItemId, "About..." ); + m_appleMenu->AppendSeparator(); + } + #if !wxOSX_USE_CARBON - m_appleMenu->Append( wxApp::s_macPreferencesMenuItemId, "Preferences..." ); - m_appleMenu->AppendSeparator(); + if ( wxApp::s_macPreferencesMenuItemId != wxID_NONE ) + { + m_appleMenu->Append( wxApp::s_macPreferencesMenuItemId, "Preferences..." ); + m_appleMenu->AppendSeparator(); + } + + // Do always add "Quit" item unconditionally however, it can't be disabled. m_appleMenu->Append( wxApp::s_macExitMenuItemId, "Quit\tCtrl+Q" ); -#endif +#endif // !wxOSX_USE_CARBON m_rootMenu->AppendSubMenu(m_appleMenu, "\x14") ; } -- 2.47.2