Description
When a user attempts to undo or redo and there are no more states in the respective stack, we should provide feedback to indicate that the action can't be performed. Right now, nothing happens, which can be confusing.
Requirements
- Play a system beep (e.g.,
NSBeep()) when undo() or redo() is called but the stack is empty.
- Disable the Undo menu item when
canUndo is false.
- Disable the Redo menu item when
canRedo is false.
- Ensure the menu item states update correctly when mutations are added or the stacks change (e.g., after
undo(), redo(), or clearStack()).
Implementation Notes
- Hook into
undo() and redo() in CEUndoManager to check if the respective stack is empty, and call NSBeep() if it is.
- Use a binding or delegate to notify the menu system to update the state of the Undo/Redo menu items when
canUndo or canRedo changes.
- Consider adding a
didUpdateUndoRedoState callback or Notification for observing changes to canUndo / canRedo.
Motivation
This improves the UX by making the application behavior more intuitive and responsive. It matches the standard macOS UX expectations for undo/redo behavior.
Description
When a user attempts to undo or redo and there are no more states in the respective stack, we should provide feedback to indicate that the action can't be performed. Right now, nothing happens, which can be confusing.
Requirements
NSBeep()) whenundo()orredo()is called but the stack is empty.canUndoisfalse.canRedoisfalse.undo(),redo(), orclearStack()).Implementation Notes
undo()andredo()inCEUndoManagerto check if the respective stack is empty, and callNSBeep()if it is.canUndoorcanRedochanges.didUpdateUndoRedoStatecallback orNotificationfor observing changes tocanUndo/canRedo.Motivation
This improves the UX by making the application behavior more intuitive and responsive. It matches the standard macOS UX expectations for undo/redo behavior.