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
This commit is contained in:
Vadim Zeitlin
2012-02-20 21:56:55 +00:00
parent 1e26459c5e
commit af46dd7bb8

View 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();
}