I currently have the issue that my CommandItems are working if I trigger them from the menu with the mouse, but nothing happens when I use the keyboard shortcut associated.
The problem occurs under Windows and with MacOS too.
I followed exactly the steps in the documentation of the ApplicationCommandManager, and basically they seem to work because the items are showing in the menu with their according shortcuts.
Does anyone have a suggestion what could cause that problem?
That’s odd. I can’t see this behaviour with the KeyMappingsDemo example or the Projucer (where we have a lot of keyboard shortcuts) on Windows or macOS. Are you using the latest JUCE? What OS are you using? Can you send a simple code snippet that reliably reproduces the behaviour?
You need to add ApplicationCommandManager's KeyPressMappingSet as a KeyListener to your top-level component so it can invoke commands when a key is pressed. Add this line to the constructor of your MainComponent:
addKeyListener (getKeyMappings());
As an aside, you shouldn’t inherit from ApplicationCommandManager and instead should have a global instance of one that you use. Take a look at how the Projucer does it, or look at the KeyMappingsDemo or MenusDemo examples.