Hi all,
I want to build an audio app with multiple document windows. In fact I want the app being able to open without any DocumentWindow
opened and then using keystrokes like command-N to open a new DocumentWindow
, later on creating a (macOS) menubar with a “New …” command.
I’ve created a custom MainApplication
class, inheriting from JUCEApplicationBase
and ApplicationCommandTarget
, copied almost all the code of JUCEApplication
and edited the virtual functions of ApplicationCommandTarget
like this:
void MainApplication::getAllCommands (Array<CommandID>& commands)
{
commands.add (StandardApplicationCommandIDs::quit);
commands.add(CommandIDs::newWindow);
}
void MainApplication::getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result)
{
switch (commandID) {
case StandardApplicationCommandIDs::quit:
result.setInfo (TRANS("Quit"),
TRANS("Quits the application"),
"Application", 0);
result.defaultKeypresses.add (KeyPress ('q', ModifierKeys::commandModifier, 0));
break;
case CommandIDs::newWindow:
result.setInfo("New Window", "opens another window", "Application", 0);
result.defaultKeypresses.add(KeyPress('n', ModifierKeys::commandModifier, 0));
break;
default:
break;
}
}
bool MainApplication::perform (const InvocationInfo& info)
{
switch (info.commandID) {
case StandardApplicationCommandIDs::quit:
systemRequestedQuit();
DBG("QUIT");
return true;
break;
case CommandIDs::newWindow:
DBG("NEW WINDOW");
createNewDocumentWindow();
return true;
break;
default:
return false;
break;
}
}
I suppose there is some kind of key listener missing for listening to the key presses when no DocumentWindow
is opened. However, Quit (cmd-Q) is working globally (as it is in JUCEApplication
).
Any ideas?
Thanks
Stefan