Logic to enable/disable redo/undo

This commit is contained in:
burnsypet
2019-03-25 19:31:10 +00:00
parent 78c6d4f005
commit b00dbbbf42

View File

@@ -179,6 +179,21 @@ class MainMenuBar(wx.MenuBar):
self.Enable(wx.ID_COPY, enable)
self.Enable(self.exportSkillsNeededId, enable)
command_history = self.mainFrame.command.GetCommands()
current_command = self.mainFrame.command.GetCurrentCommand()
self.Enable(wx.ID_UNDO, True)
self.Enable(wx.ID_REDO, True)
if len(command_history) == 0:
self.Enable(wx.ID_UNDO, False)
self.Enable(wx.ID_REDO, False)
else:
if current_command not in command_history:
self.Enable(wx.ID_UNDO, False)
if current_command == command_history[len(command_history) - 1]:
self.Enable(wx.ID_REDO, False)
sChar = Character.getInstance()
charID = self.mainFrame.charSelection.getActiveCharacter()
char = sChar.getCharacter(charID)