From af46dd7bb88dbd9a8658d49f088ea5f606955916 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 20 Feb 2012 21:56:55 +0000 Subject: [PATCH] Allow handling EVT_UPDATE_UI for wxID_UNDO/REDO at wxDocument level. 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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index eba884d..5df2030 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -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(); } -- 2.7.4