re-added support for help-menu and application-menu items
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -439,10 +439,22 @@ static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler
|
|||||||
|
|
||||||
wxMenuItem* item = NULL ;
|
wxMenuItem* item = NULL ;
|
||||||
MenuCommand id = command.commandID ;
|
MenuCommand id = command.commandID ;
|
||||||
// for items we don't really control
|
|
||||||
if ( id == kHICommandPreferences )
|
// for 'standard' commands
|
||||||
|
if ( id == kHICommandPreferences || id == kHICommandQuit || id == kHICommandAbout )
|
||||||
{
|
{
|
||||||
|
switch ( id )
|
||||||
|
{
|
||||||
|
case kHICommandPreferences :
|
||||||
id = wxApp::s_macPreferencesMenuItemId ;
|
id = wxApp::s_macPreferencesMenuItemId ;
|
||||||
|
break ;
|
||||||
|
case kHICommandQuit :
|
||||||
|
id = wxApp::s_macExitMenuItemId ;
|
||||||
|
break ;
|
||||||
|
case kHICommandAbout :
|
||||||
|
id = wxApp::s_macAboutMenuItemId ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
if ( mbar )
|
if ( mbar )
|
||||||
@@ -452,17 +464,41 @@ static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( id != 0 && command.menu.menuRef != 0 && command.menu.menuItemIndex != 0 )
|
else if ( id != 0 && command.menu.menuRef != 0 && command.menu.menuItemIndex != 0 )
|
||||||
|
{
|
||||||
|
// make sure it is one of our own menus, or of the 'synthetic' apple and help menus , otherwise don't touch
|
||||||
|
MenuItemIndex firstUserHelpMenuItem ;
|
||||||
|
static MenuHandle mh = NULL ;
|
||||||
|
if ( mh == NULL )
|
||||||
|
{
|
||||||
|
if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) != noErr )
|
||||||
|
{
|
||||||
|
mh = NULL ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// is it part of the application or the help menu, then look for the id directly
|
||||||
|
if ( ( GetMenuHandle( kwxMacAppleMenuId ) != NULL && command.menu.menuRef == GetMenuHandle( kwxMacAppleMenuId ) ) ||
|
||||||
|
( mh != NULL && command.menu.menuRef == mh ) )
|
||||||
|
{
|
||||||
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
|
if ( mbar )
|
||||||
|
{
|
||||||
|
wxMenu* menu = NULL ;
|
||||||
|
item = mbar->FindItem( id , &menu ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
wxMenu* itsMenu = NULL ;
|
wxMenu* itsMenu = NULL ;
|
||||||
UInt32 refCon ;
|
UInt32 refCon ;
|
||||||
GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , &refCon ) ;
|
GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , &refCon ) ;
|
||||||
// make sure it is one of our own menus, otherwise don't touch
|
|
||||||
itsMenu = wxFindMenuFromMacMenu( command.menu.menuRef ) ;
|
itsMenu = wxFindMenuFromMacMenu( command.menu.menuRef ) ;
|
||||||
if ( itsMenu != NULL )
|
if ( itsMenu != NULL )
|
||||||
{
|
{
|
||||||
item = (wxMenuItem*) refCon ;
|
item = (wxMenuItem*) refCon ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user