]> git.saurik.com Git - wxWidgets.git/commitdiff
Allow setting Mac-specific menu item ids to wxID_NONE to suppress them.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Sep 2010 19:36:37 +0000 (19:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Sep 2010 19:36:37 +0000 (19:36 +0000)
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

index e251fa461d7762bfab13dc521ddbc9ca24e21d14..4ee92302bd3ee344107ed9166db62d58af6bb103 100644 (file)
@@ -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") ;
 }