Clear stuck shortcut keys when the main window loses focus (#11548)#11967
Merged
niksedk merged 1 commit intoJun 29, 2026
Merged
Conversation
…dit#11548) A modal dialog steals focus from the main window, so the KeyUp for any keys held when it opened never reaches the main window's key handler and those keys stay "down" in the shortcut manager. Most visibly: pressing Ctrl+O on a changed file raises the "Save changes?" prompt; after dismissing it, Ctrl+I (toggle italic), Find, Replace and every other shortcut stop matching, because the active-key set is still {Ctrl, O, ...}. It only recovered via an action that happened to call ClearKeys. Clear the held-key state in OnWindowDeactivated, which already runs whenever the window loses focus (modal dialogs, Alt+Tab), so the set is empty again the next time the window is active.
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.
Fixes #11548.
Problem: a modal dialog steals focus, so the KeyUp for keys held when it opened never reaches the main window and they stay 'down' in the shortcut manager. Most visibly: Ctrl+O on a changed file raises the 'Save changes?' prompt; after dismissing it, Ctrl+I (toggle italic), Find, Replace and every other shortcut stop matching (active set is still {Ctrl, O, …}). Reproduced on Linux per the issue.
Fix: clear the held-key state in
OnWindowDeactivated, which already runs whenever the window loses focus (modal dialogs, Alt+Tab), so the set is empty again next time the window is active. One-line, cross-platform.Developed on macOS; verified compiling via CI.