Fix the activation of the toolbar's Undo and Redo buttons - #2404
Merged
Merged
Conversation
ToolBar::CanRedo() enabled or disabled wxID_UNDO, so Redo never changed state and Undo followed whichever of the two was set last. Also, AddTools() re-creates every tool enabled but kept the remembered states CanUndo(), CanCopy(), ... compare against, so after the user showed or hid a group of tools a button could stay active with nothing to act on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q7P4rJ2sLJfF5fWc6JgT7n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Gunter · project thread
Before: the toolbar's Redo button never changed state. Whether there was something to redo switched the Undo button instead, so Undo followed whichever of the two was updated last. After showing or hiding a group of toolbar buttons from the toolbar's context menu, buttons with nothing to act on (Undo, Copy, ...) could stay active.
After: Undo and Redo each follow their own state, and re-created tools become inactive again at the next update.
How:
ToolBar::CanRedo()now enableswxID_REDOrather thanwxID_UNDO.AddTools()re-creates every tool enabled, but the remembered states thatCanUndo(),CanCopy(), ... compare against were kept, so an update to "disabled" was skipped as redundant.AddTools()now resets them.Test:
test_ToolBarUndoRedocovers both. With the two fixes reverted, both scenarios fail; with them, all 55 unit tests pass. Found while fixing #2403, which touches the same header but not the same lines.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q7P4rJ2sLJfF5fWc6JgT7n
Generated by Claude Code