I’m trying to change the menu bar commands from not active to active. I do this by changing ApplicationCommandInfo::setActive inside my component’s implementation of getCommandInfo.
As far as I understand, the way to “refresh” the command status is by calling commandStatusChanged(), yet it isn’t causing getCommandInfo() to get called, and in turn it means the menu item remains disabled.
The problem seems to be related to the ApplicationCommandManager not finding my component (although somehow it does find it every time when performing a command, no problems there).
My component does implement getNextCommandTarget() returning findFirstTargetParentComponent() and it is the only component that implements the ApplicationCommandTarget “protocol”.
Finally, I also tried to set my component as the first command target by calling getFirstCommandTarget(), but it asserts because of some check that the target and the next target are the same.
So at this point calling commandStatusChanged() only calls the App’s default implementation of getNextCommandTarget() which returns null, never reaching my component :-(.
Here’s some pseudo-code of how my app is set up:
MyApp : public JUCEApplication // by default returns nullptr for getNextCommandTarget()
MyMainWindow : public DocumentWindow, public MenuBarModel // sets up some special menu items in its constructor
MyMainComponent : public ApplicationCommandTarget // this is the window’s content component and primary app controller, in charge of handling all the commands.
Any help figuring this out will be greatly appreciated.