Fix keyboard handling when Visage is hosted inside a plugin on macOS#81
Open
danielraffel wants to merge 1 commit intoVitalAudio:mainfrom
Open
Fix keyboard handling when Visage is hosted inside a plugin on macOS#81danielraffel wants to merge 1 commit intoVitalAudio:mainfrom
danielraffel wants to merge 1 commit intoVitalAudio:mainfrom
Conversation
Two related issues when a Visage view is embedded inside a host application (e.g. an audio plugin running in a DAW): 1. Command-key shortcuts (Cmd+C, Cmd+V, Cmd+A, Cmd+X, Cmd+Z) never reach Visage text editors. On macOS, the host's menu system handles performKeyEquivalent: before keyDown: is called, so the host's Edit menu intercepts these shortcuts. Add a performKeyEquivalent: override that checks hasActiveTextEntry(). When a text editor has focus, route the shortcut through handleKeyDown so copy/paste/select-all/undo work. When no text editor is active, fall through to the host so its menu shortcuts keep working normally. 2. Unhandled command-key events (like Cmd+Q) get silently swallowed. [super keyDown:] on macOS does not propagate events up the responder chain — it just consumes them. So Cmd+Q never reaches the application-level handler. Forward unhandled command-key events to [self nextResponder] instead of [super keyDown:] so they propagate up to the app.
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.
Two related issues when a Visage view is embedded inside a host application (e.g. an audio plugin running in a DAW):
1. Text editing shortcuts don't work (Cmd+C/V/X/A/Z)
On macOS, the host's menu system handles
performKeyEquivalent:beforekeyDown:is called. The host's Edit menu intercepts Cmd+C, Cmd+V, etc., so they never reach Visage text editors.This adds a
performKeyEquivalent:override that checkshasActiveTextEntry(). When a text editor has focus, the shortcut is routed throughhandleKeyDownso copy/paste/select-all/undo work. When no text editor is active, the event falls through to the host so its menu shortcuts keep working normally.2. Unhandled command-key events are silently swallowed
[super keyDown:]on macOS does not propagate events up the responder chain — it consumes them. So shortcuts like Cmd+Q never reach the application-level handler.This forwards unhandled command-key events to
[self nextResponder]instead of[super keyDown:]so they propagate up to the app. Non-command keys still go through[super keyDown:]as before.Discovered while working on a macOS JUCE audio plugin that uses Visage for its UI. This PR was put together with the help of Claude. Completely understand if you'd prefer to close this — just wanted to share the fixes since we've been patching around them on our end whenever we update Visage.