Keyboard Focus issue


We are having problems with keyboard focus when a 3rd party hosted plugin’s GUI is focused. We have tried setting the Plugin editor requires keyboard focus to false and have tried to implement this independently with the following

    if (isActiveWindow()) {

and varied this to

    activePluginWindows.removeFirstMatchingValue (this);

We have also tried

PluginWindow::PluginWindow (Component* const uiComp,
                            AudioProcessor * owner_,
                            const bool isGeneric_)
: DocumentWindow (uiComp->getName(), Colours::lightblue,
                  DocumentWindow::minimiseButton | DocumentWindow::closeButton | DocumentWindow::setWantsKeyboardFocus(false);),

and tried adding

isGeneric (isGeneric_)

But none of these have worked, the focused window still steals keyboard focus, which is preventing Spacebar playback in the DAW whilst the 3rd party plugin GUI is focused.


The plugin’s window is free to call OS functions directly to give itself focus, and as a host there’s not much you can do about it.

One solution is to always capture spacebar presses, and dispatch them to subcomponents are required.


Hi Tom,

Please help us how to dispatch them to subcomponents?
Is there a way to send a space key to parent components?



Something like this:

class TestWindow : public DocumentWindow
    TestWindow ()
        : DocumentWindow ("test", Colours::red, 0)

    bool keyPressed (const KeyPress& key) override
        DBG ("Key pressed in window!");
        return false;

class MainContentComponent : public Component,
                             public KeyListener
        setSize (600, 400);

        testWindow.setVisible (true);

        testWindow.addKeyListener (this);

    ~MainContentComponent() {}

    void paint (Graphics& g) override {}

    void resized() override {}

    bool keyPressed (const KeyPress& key, Component* originatingComponent) override
        DBG ("Caught key pressed!");
        return false;

    TestWindow testWindow;


The return value of keyPressed indicates if you are going to consume the key press there or pass it along to the next component.


Thanks for your answer.
I am trying your proposal now. and keep you updated.
Additional question:
When i press space bar on the main plugin window, i dont see the plugin handle the key pressed handler.
I just need to play track on DAWs.
Is there a way to do that ?



I can hook the key from the document window.
But i can’t send it to daw to play the track.

I tried :slight_smile:
Return false on keypress event. But no result.

I need to send space key i hook above and send it to daw.

Now i dont know how to send space key to Daw.
Please give me more idea


Perhaps I misunderstood your use case.

If your application is a plug-in host then the above approach may work. If, however, you are trying to send a spacebar press to an external host from inside a plug-in GUI then I don’t know what will work; it’s the host’s responsibility to capture key presses it might be interested in.


Thanks man.

I updated the information on attached image.

Jules can help me (hi hi hi hi i hope that).

Thanks all guy


Tom already looked into this, and like he says, it’s not something we consider to be working incorrectly. Hosts generally use some hacky tricks to spy on keypresses that happen inside your plugin window, but if you start creating your own separate windows, you can’t expect the host to pay any attention to them.

All I can suggest would be that you catch spacebar presses yourself in your floating window, and then write your own win32 code to inject space key events into your plugin’s HWND, so that host may spot them.



I considered your solution.
I am still looking for easier way to do that.

Keep this question open, if noone can answer this question. I ll try your proposal.
Thanks Jules,


I fixed that with easy way.


Hi hungj,
May I ask you what is the easy way you found ?