Fix menu event propogation to be consistent across platforms, and with
the docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19968 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2363,28 +2363,12 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
|
|||||||
MenuCommand id ;
|
MenuCommand id ;
|
||||||
GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ;
|
GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ;
|
||||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
wxMenu* menu = NULL ;
|
wxFrame* frame = mbar->GetFrame();
|
||||||
wxMenuItem* item = NULL ;
|
wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
|
||||||
if ( mbar )
|
if ( frame )
|
||||||
{
|
{
|
||||||
item = mbar->FindItem( id , &menu ) ;
|
frame->ProcessCommand(id);
|
||||||
}
|
}
|
||||||
wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
|
|
||||||
|
|
||||||
if (item->IsCheckable())
|
|
||||||
{
|
|
||||||
item->Check( !item->IsChecked() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
|
||||||
/*
|
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
|
||||||
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
|
||||||
event.SetEventObject(menu);
|
|
||||||
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
|
||||||
frontwindow->GetEventHandler()->ProcessEvent(event);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
@@ -2363,28 +2363,12 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
|
|||||||
MenuCommand id ;
|
MenuCommand id ;
|
||||||
GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ;
|
GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ;
|
||||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
wxMenu* menu = NULL ;
|
wxFrame* frame = mbar->GetFrame();
|
||||||
wxMenuItem* item = NULL ;
|
wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
|
||||||
if ( mbar )
|
if ( frame )
|
||||||
{
|
{
|
||||||
item = mbar->FindItem( id , &menu ) ;
|
frame->ProcessCommand(id);
|
||||||
}
|
}
|
||||||
wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
|
|
||||||
|
|
||||||
if (item->IsCheckable())
|
|
||||||
{
|
|
||||||
item->Check( !item->IsChecked() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
|
||||||
/*
|
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
|
||||||
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
|
||||||
event.SetEventObject(menu);
|
|
||||||
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
|
||||||
frontwindow->GetEventHandler()->ProcessEvent(event);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
@@ -384,11 +384,12 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
MenuCommand id ;
|
MenuCommand id ;
|
||||||
GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ;
|
GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ;
|
||||||
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
wxMenuItem* item = menu->FindChildItem(id);
|
||||||
event.m_timeStamp = TickCount() ;
|
if (item->IsCheckable())
|
||||||
event.SetEventObject(this->GetEventHandler());
|
{
|
||||||
event.SetInt( id );
|
item->Check( !item->IsChecked() );
|
||||||
GetEventHandler()->ProcessEvent(event);
|
}
|
||||||
|
menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
}
|
}
|
||||||
::DeleteMenu( menu->MacGetMenuId() ) ;
|
::DeleteMenu( menu->MacGetMenuId() ) ;
|
||||||
menu->SetInvokingWindow(NULL);
|
menu->SetInvokingWindow(NULL);
|
||||||
|
@@ -384,11 +384,12 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
MenuCommand id ;
|
MenuCommand id ;
|
||||||
GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ;
|
GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ;
|
||||||
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
wxMenuItem* item = menu->FindChildItem(id);
|
||||||
event.m_timeStamp = TickCount() ;
|
if (item->IsCheckable())
|
||||||
event.SetEventObject(this->GetEventHandler());
|
{
|
||||||
event.SetInt( id );
|
item->Check( !item->IsChecked() );
|
||||||
GetEventHandler()->ProcessEvent(event);
|
}
|
||||||
|
menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
}
|
}
|
||||||
::DeleteMenu( menu->MacGetMenuId() ) ;
|
::DeleteMenu( menu->MacGetMenuId() ) ;
|
||||||
menu->SetInvokingWindow(NULL);
|
menu->SetInvokingWindow(NULL);
|
||||||
|
Reference in New Issue
Block a user