cmajor icon indicating copy to clipboard operation
cmajor copied to clipboard

Sending keyboard events from plugin window to host (missing feature?)

Open sorenjakobsen opened this issue 9 months ago • 2 comments

It seems that we are missing a way to have keyboard events 'bubble up' from a plugin window to the host?

For example, if you generate a JUCE project from the example SineSynth and compile it into a VST3 that you load into Ableton - you are able to use the computer keyboard to play the synth. It is essential that you are also able to play the synth this way when the plugin window is open and focused, but it seems that is not possible.

I know that we can capture the key stroke events and react to them directly inside the plugin code, but we also need to respect the state - i.e. the selected octave - of the computer keyboard (of the host). So it would be better to be able to pass on the key stroke events to host, which can then in turn pass midi events back into the plugin.

Being able to pass on key stroke events to the host should also enable us to start playback in the host - using the space bar - while using the plugin UI, which is also essential.

NB. It seems with Projucer there is an option to enable/disable the ability of the plugin window to 'capture' keyboard focus (the settings option 'Plugin Editor Requires Keyboard Focus') - if the plugin window can never get keyboard focus the keyboard events will always go to the host. However, the cmajor tool does not generate a .jucer file, so I guess it is not possible to access that option. And also, it can be necessary for the plugin window to have keyboard focus (e.g. if there are text input controls in its UI) - so it should be possible to programmatically toggle focus on and off the plugin window (controls), or to programmatically choose when keyboard events are to be 'bubbled up'.

sorenjakobsen avatar Apr 01 '25 09:04 sorenjakobsen

Yep, adding some mechanism to selectively allow keypress events to escape the browser is already a to-do item for us, but it's not trivial - requires platform-specific hackery and a lot of testing.

In the meantime, that JUCE flag is available in cmake (or any build system), you just need to set the macro flag for it.

julianstorer avatar Apr 01 '25 12:04 julianstorer

Great, I'm really glad to hear that. I will be ready to help with testing on Windows:)

sorenjakobsen avatar Apr 01 '25 16:04 sorenjakobsen