X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e39af974ef7846e26686ae39d74e4696c1fef0c3..99e8cb505ad94704ec6596d20842ca8fa34e7d9e:/src/mac/app.cpp diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 1af5aa871f..04f3eee3b5 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -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