preliminary implementation of wxEVT_MENU_OPEN/CLOSE for Mac

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21835 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-07-10 01:20:52 +00:00
parent e4b712e245
commit e32f4a9fa9
3 changed files with 63 additions and 4 deletions

View File

@@ -288,6 +288,9 @@ void wxApp::MacNewFile()
{ kEventClassCommand, kEventProcessCommand } ,
{ kEventClassCommand, kEventCommandUpdateStatus } ,
{ kEventClassMenu, kEventMenuOpening },
{ kEventClassMenu, kEventMenuClosed },
{ kEventClassApplication , kEventAppActivated } ,
{ kEventClassApplication , kEventAppDeactivated } ,
// handling the quit event is not recommended by apple
@@ -299,9 +302,35 @@ void wxApp::MacNewFile()
{ 'WXMC' , 'WXMC' }
} ;
static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
static pascal OSStatus
MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
return eventNotHandledErr ;
// FIXME: this doesn't work for multiple windows
wxWindow *win = wxTheApp->GetTopWindow();
if ( win )
{
// VZ: we could find the menu from its handle here by examining all
// the menus in the menu bar recursively but knowing that neither
// wxMSW nor wxGTK do it why bother...
#if 0
MenuRef menuRef;
GetEventParameter(event,
kEventParamDirectObject,
typeMenuRef, NULL,
sizeof(menuRef), NULL,
&menuRef);
#endif // 0
wxMenuEvent event(GetEventKind(event) == kEventMenuOpening
? wxEVT_MENU_OPEN
: wxEVT_MENU_CLOSE);
event.SetEventObject(win);
(void)win->GetEventHandler()->ProcessEvent(event);
}
return eventNotHandledErr;
}
// due to the rather low-level event API of wxWindows, we cannot use RunApplicationEventLoop