]> git.saurik.com Git - wxWidgets.git/commitdiff
Allow handling EVT_UPDATE_UI for wxID_UNDO/REDO at wxDocument level.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 20 Feb 2012 21:56:55 +0000 (21:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 20 Feb 2012 21:56:55 +0000 (21:56 +0000)
Don't require using wxCommandProcessor for this, only use it if it exists.

Closes #14011.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70651 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/docview.cpp

index eba884d600cce306ca3bdd636b3fcca7951793ad..5df20303415862c9abaf33c29b9518b869c96a3d 100644 (file)
@@ -1319,10 +1319,14 @@ void wxDocManager::OnUpdateUndo(wxUpdateUIEvent& event)
     wxCommandProcessor * const cmdproc = GetCurrentCommandProcessor();
     if ( !cmdproc )
     {
-        event.Enable(false);
+        // If we don't have any document at all, the menu item should really be
+        // disabled.
+        if ( !GetCurrentDocument() )
+            event.Enable(false);
+        else // But if we do have it, it might handle wxID_UNDO on its own
+            event.Skip();
         return;
     }
-
     event.Enable(cmdproc->CanUndo());
     cmdproc->SetMenuStrings();
 }
@@ -1332,10 +1336,13 @@ void wxDocManager::OnUpdateRedo(wxUpdateUIEvent& event)
     wxCommandProcessor * const cmdproc = GetCurrentCommandProcessor();
     if ( !cmdproc )
     {
-        event.Enable(false);
+        // Use same logic as in OnUpdateUndo() above.
+        if ( !GetCurrentDocument() )
+            event.Enable(false);
+        else
+            event.Skip();
         return;
     }
-
     event.Enable(cmdproc->CanRedo());
     cmdproc->SetMenuStrings();
 }