Keyboard focus lost on instantiation in Mac Reaper VST


I've found an issue that I can replicate with the Juce Demo Plugin using the tip.

In Mac Reaper, when instantiating the VST version of the plug-in or reopening its GUI, the keyboard focus seems to be lost and no key strokes (e.g. space bar) reach the host or the plug-in. As soon as the background of the plug-in is clicked or the tab key is pressed the keyboard focus goes to the plug-in and the problem gets solved.

When debugging, I can see that Component::currentlyFocusedComponent is null while the problem exists.

I can only replicate this behaviour in Reaper using the VST version of the plug-in, not the AU, and when opening the GUI double clicking on the mixer insert instead of through the FX button, it seems to only happen when the GUI opens on its own and not embedded in the FX window.


I can solve this issue by adding "editorComp->grabKeyboardFocus();" at the end of opCode 'effEditOpen' in JuceVSTWrapper::dispatcher(). Is there any reason why this might not be a good idea?



It's not guaranteed that all hosts will call that function on the message thread, so it's unsafe to call any GUI functions. You could post a message that asynchronously grabs focus, though.

Great, thanks!