Main menu command shortcuts stop working

The command shortcuts for the main menu stop working as soon as another DocumentWindow is opened and has focus.

Pressing CMD+S for example (global save command) will flash the main menu just as if the save was performed, but the command never executes.

This is reproducible in the latest PluginHost example as well. Just open the PluginHost example, then double click on any plugin you have an while that window is up and has focus you cannot press CMD+S to save the entire graph.
Once you click back onto the main window it works again.

Is this a real bug or or am I missing something obvious here? Is there a workaround?

This is really just an oddity with the plug-in host as it registers almost all of it’s commands with the window as the target. During startup, the plug-in host calls commandManager.registerAllCommandsForTarget (mainWindow); which in turn adds most of the app’s commands. Therefore, all those commands will only work when the mainWindow has focus.

I see. What is the correct way to add a global menu that is always active regardless of the currently used window within the application?

Register your JUCEApplication class as the command target and put all your commands in there including your MenuBarModel.

Ahh… yes - that makes sense.


Sorry Fabian, but after I moved everything to the Application class - same thing happens if another window within the app has focus. I call these during the initialization of the app. “this” is obviously the JUCEApplication class in this case.


There is nothing in the main window that would be now responsible for this. It is no longer a subclass of MenuBarModel either.

What could be the culprit here?

The issue had nothing to do with registering the app as the only command target.

The problem was that the command manager KEY MAPPINGS must be added to each document window manually or the shortcuts will not work if the focused window received the keyboard shortcut.

Hopefully this will help someone else…