1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Use global ApplicationCommandManager in KeyMappingsDemo and MenusDemo when running in DemoRunner

This commit is contained in:
ed 2021-05-17 16:19:35 +01:00
parent dda48ebec3
commit 2e5509f401
4 changed files with 26 additions and 2 deletions

View file

@ -157,6 +157,10 @@ public:
setApplicationCommandManagerToWatch (&commandManager);
commandManager.registerAllCommandsForTarget (this);
// this ensures that commands invoked on the DemoRunner application are correctly
// forwarded to this demo
commandManager.setFirstCommandTarget (this);
// this lets the command manager use keypresses that arrive in our window to send out commands
addKeyListener (commandManager.getKeyMappings());
@ -174,6 +178,8 @@ public:
#if JUCE_MAC
MenuBarModel::setMacMainMenu (nullptr);
#endif
commandManager.setFirstCommandTarget (nullptr);
}
void resized() override
@ -316,7 +322,11 @@ public:
}
private:
#if JUCE_DEMO_RUNNER
ApplicationCommandManager& commandManager = getGlobalCommandManager();
#else
ApplicationCommandManager commandManager;
#endif
std::unique_ptr<MenuBarComponent> menuBar;
MenuBarPosition menuBarPosition = MenuBarPosition::window;