Confusion re setCommandToTrigger with clickTogglesState on

I have started using ApplicationCommandManager, and things have been going OK until I hit the following assertion message . .

// if you've got clickTogglesState turned on, you shouldn't also connect the button // up to be a command invoker. Instead, your command handler must flip the state of whatever // it is that this button represents, and the button will update its state to reflect this // in the applicationCommandListChanged() method.

Does “flip the state” mean ApplicationCommandInfo flags? What alternative method am I supposed to use to invoke the command if the button cannot be a command invoker. Many thanks.

Yes, you would change the state of something in your app, and the next time that command info is queried you can report it (therefore the button state changes). I think there’s a way to mark the commands need updating.

Another way is to use a button listener.

But the most up to date method is to link the button to a value. Clicking the button will change the value and change the button’s visible state.


Thanks Bruce, so where do I report the state change and how do I force the update? Do I do it in the overloaded method . .

void getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result) { switch (commandID) { ... result.setTicked(getAboolFromTheDataModel)

Then re-register all commands for target?

Call ApplicationCommandManager::commandStatusChanged() then yes, report the item as enabled (ticked?).

But you should also look at Values and ValuTrees.