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:
@@ -147,6 +147,7 @@ wxGTK:
|
|||||||
wxMac:
|
wxMac:
|
||||||
|
|
||||||
- generate wxEVT_SCROLL_THUMBRELEASE and wxEVT_SCROLLWIN_THUMBRELEASE events
|
- generate wxEVT_SCROLL_THUMBRELEASE and wxEVT_SCROLLWIN_THUMBRELEASE events
|
||||||
|
- generate wxEVT_MENU_OPEN and wxEVT_MENU_CLOSE events
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -288,6 +288,9 @@ void wxApp::MacNewFile()
|
|||||||
{ kEventClassCommand, kEventProcessCommand } ,
|
{ kEventClassCommand, kEventProcessCommand } ,
|
||||||
{ kEventClassCommand, kEventCommandUpdateStatus } ,
|
{ kEventClassCommand, kEventCommandUpdateStatus } ,
|
||||||
|
|
||||||
|
{ kEventClassMenu, kEventMenuOpening },
|
||||||
|
{ kEventClassMenu, kEventMenuClosed },
|
||||||
|
|
||||||
{ kEventClassApplication , kEventAppActivated } ,
|
{ kEventClassApplication , kEventAppActivated } ,
|
||||||
{ kEventClassApplication , kEventAppDeactivated } ,
|
{ kEventClassApplication , kEventAppDeactivated } ,
|
||||||
// handling the quit event is not recommended by apple
|
// handling the quit event is not recommended by apple
|
||||||
@@ -299,8 +302,34 @@ void wxApp::MacNewFile()
|
|||||||
{ 'WXMC' , 'WXMC' }
|
{ 'WXMC' , 'WXMC' }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
static pascal OSStatus
|
||||||
|
MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||||
{
|
{
|
||||||
|
// 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;
|
return eventNotHandledErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -288,6 +288,9 @@ void wxApp::MacNewFile()
|
|||||||
{ kEventClassCommand, kEventProcessCommand } ,
|
{ kEventClassCommand, kEventProcessCommand } ,
|
||||||
{ kEventClassCommand, kEventCommandUpdateStatus } ,
|
{ kEventClassCommand, kEventCommandUpdateStatus } ,
|
||||||
|
|
||||||
|
{ kEventClassMenu, kEventMenuOpening },
|
||||||
|
{ kEventClassMenu, kEventMenuClosed },
|
||||||
|
|
||||||
{ kEventClassApplication , kEventAppActivated } ,
|
{ kEventClassApplication , kEventAppActivated } ,
|
||||||
{ kEventClassApplication , kEventAppDeactivated } ,
|
{ kEventClassApplication , kEventAppDeactivated } ,
|
||||||
// handling the quit event is not recommended by apple
|
// handling the quit event is not recommended by apple
|
||||||
@@ -299,8 +302,34 @@ void wxApp::MacNewFile()
|
|||||||
{ 'WXMC' , 'WXMC' }
|
{ 'WXMC' , 'WXMC' }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
static pascal OSStatus
|
||||||
|
MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||||
{
|
{
|
||||||
|
// 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;
|
return eventNotHandledErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user