ApplicationCommandTarget , using same key to do different things depending on current focus (ctrl-x, for example)

The “JUCE way” of handling context-dependant commands is really by updating your command manager and its status (ie: call commandStatusChanged). From here, the set up is fairly simple though tedious to do.

In your subclasses of ApplicationCommandTarget, you’ll have to produce the commands you need in this new context (see getAllCommands), then you’ll need to reset each command as per your new context (in your getCommandInfo, make the result command info active, set its name, change its tooltip, reconfigure the shortcut(s), etc…).

If the flow changes for your commands, as in your targets change, you’ll have to change your first command target and subsequent targets from there.

This is such a typical kind of pattern, where a context is defined by a “screen” concept (where there are modes of operation, which is an extremely popular design strategy for mobile apps), hence why I suggested this feature: FR: Cross-Platform Navigation Controller

3 Likes