Bug/Windows: Hosted VST plugin's keyboard focus is buggy

My Windows/Mac application hosts VST/AU plugins.

My used Component hierarchy is this, listed from parent to child order:

#1: juce::DocumentWindow (setContentNonOwned() is used to give the below Component to it)
#2: juce::Component (parent for the VST/AU GUI)
#3: AudioProcessorEditor (the VST/AU plugin GUI)

In the Component #2 (the parent for the VST/AU GUI) I use the following to get the VST/AU GUI:

       AudioProcessorEditor* AudioProcessor::createEditorIfNeeded()

Then I use addAndMakeVisible() to make that AudioProcessorEditor a child of this component (Component #2).

Component #2 has the following settings:

        setInterceptsMouseClicks(true, true);

Component #1 has a keyboard listener added to it, which monitors computer keyboard key presses.

On Mac everything works correctly:
I can click any part of the DocumentWindow, including the VST/AU GUI area and all keyboard presses are recorded properly by the keyboard listener.

On Windows things get buggy:
If I click any part of the window or its child components but not the actual VST GUI itself, key presses are recorded correctly. But if I click the VST GUI area, nothing gets recorded by the keyboard listener.

This doesn’t seem to get fixed by adding keyboard listener also to the VST plugin GUI itself.
Also things don’t get better if I use setWantsKeyboardFocus() and/or setMouseClickGrabsKeyboardFocus() for the plugin GUI component, regardless of what settings I use for them.
Also setting setWantsKeyboardFocus(false) and setMouseClickGrabsKeyboardFocus(false) for the Component #2 doesn’t seem to fix this issue.

On Mac everything works fine for both VST and AU plugins.
The bug happens only on Windows.

I made three more tests about this issue.



    setInterceptsMouseClicks(false, false);

    p_vst_plugin_gui->setInterceptsMouseClicks(false, false);

With the above settings, after VST plugin GUI area has been clicked with the mouse, the keyboard focus gets stolen by the VST plugin GUI. None of the key presses go to the parent Component which contains the VST plugin GUI.

I have to click some parent Component which does accept mouse clicks and/or accepts keyboard focus, to receive keyboard events by any of the JUCE Components.


I did the same as above, but made the parent Component (which has VST plugin GUI as child Component) a juce::KeyListener. I added this parent Component as listener to the VST plugin GUI and added the respective public virtual methods.

When I clicked the VST plugin GUI area with mouse and started typing with keyboard, the KeyListener methods were not called when keyboard events should have happened.

I even tried it with the following settings and the result was still the same:


    setInterceptsMouseClicks(true, true);

    p_vst_plugin_gui->setInterceptsMouseClicks(true, true);


I made the juce::DocumentWindow (which contains the Component, which contains the VST plugin GUI) to have the settings:

    setInterceptsMouseClicks(false, false);

The result was exactly the same: if you click the VST plugin GUI area, it steals the keyboard focus again and no keyboard events are received by the JUCE.

Again, this happens on Windows only.