X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..7124df9b59f2627c083b1fecaaa3e93c7088e3d0:/src/common/framecmn.cpp diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index 3d94d675e1..3cc2dff527 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -196,15 +196,17 @@ bool wxFrameBase::ProcessCommand(int id) if ( !bar ) return FALSE; + wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); + commandEvent.SetEventObject(this); + wxMenuItem *item = bar->FindItem(id); if ( item && item->IsCheckable() ) { item->Toggle(); - } - wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); - commandEvent.SetInt(id); - commandEvent.SetEventObject(this); + // use the new value + commandEvent.SetInt(item->IsChecked()); + } return GetEventHandler()->ProcessEvent(commandEvent); } @@ -425,18 +427,23 @@ void wxFrameBase::DoMenuUpdates() { wxMenuBar* bar = GetMenuBar(); +#ifdef __WXMSW__ + wxWindow* focusWin = wxFindFocusDescendant((wxWindow*) this); +#else + wxWindow* focusWin = (wxWindow*) NULL; +#endif if ( bar != NULL ) { int nCount = bar->GetMenuCount(); for (int n = 0; n < nCount; n++) - DoMenuUpdates(bar->GetMenu(n), (wxWindow*) NULL); + DoMenuUpdates(bar->GetMenu(n), focusWin); } } // update a menu and all submenus recursively -void wxFrameBase::DoMenuUpdates(wxMenu* menu, wxWindow* WXUNUSED(focusWin)) +void wxFrameBase::DoMenuUpdates(wxMenu* menu, wxWindow* focusWin) { - wxEvtHandler* evtHandler = GetEventHandler(); + wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler(); wxMenuItemList::Node* node = menu->GetMenuItems().GetFirst(); while (node) {