]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/framecmn.cpp
fix for assert when setting tooltip for a readonly combo
[wxWidgets.git] / src / common / framecmn.cpp
index 3d94d675e1c6fd7eda261a6758e353947af197b6..3cc2dff527d745502ad526e86202dea0702c1870 100644 (file)
@@ -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)
     {