added toggle support (and some corrections ;-)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17573 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2320,12 +2320,26 @@ 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() ;
|
||||||
|
wxMenu* menu = NULL ;
|
||||||
|
wxMenuItem* item = NULL ;
|
||||||
|
if ( mbar )
|
||||||
|
{
|
||||||
|
item = mbar->FindItem( id , &menu ) ;
|
||||||
|
}
|
||||||
|
wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
|
||||||
|
|
||||||
|
if (item->IsCheckable())
|
||||||
|
{
|
||||||
|
item->Check( !item->IsChecked() ) ;
|
||||||
|
}
|
||||||
|
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
||||||
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
||||||
event.SetEventObject(frontwindow->GetEventHandler());
|
event.SetEventObject(menu);
|
||||||
event.SetInt( id );
|
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
frontwindow->GetEventHandler()->ProcessEvent(event);
|
frontwindow->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
@@ -2320,12 +2320,26 @@ 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() ;
|
||||||
|
wxMenu* menu = NULL ;
|
||||||
|
wxMenuItem* item = NULL ;
|
||||||
|
if ( mbar )
|
||||||
|
{
|
||||||
|
item = mbar->FindItem( id , &menu ) ;
|
||||||
|
}
|
||||||
|
wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
|
||||||
|
|
||||||
|
if (item->IsCheckable())
|
||||||
|
{
|
||||||
|
item->Check( !item->IsChecked() ) ;
|
||||||
|
}
|
||||||
|
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
||||||
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
||||||
event.SetEventObject(frontwindow->GetEventHandler());
|
event.SetEventObject(menu);
|
||||||
event.SetInt( id );
|
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
frontwindow->GetEventHandler()->ProcessEvent(event);
|
frontwindow->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user