Change the name of a menu entry


#1

Depending on the state of my app I would like to show a “Play” or “Pause” menu entry created using application commands. It seems registered commands can’t be changed after they have been registered with the ApplicationCommandManager. How can I change an existing command, eg. change its short text so that the menu entry correctly show “Pause” during audio playback and “Play” when audio playback is paused.


#2

If you send a “commands changed” message, it should re-check all the names, so as long as your command target returns the new name, it should pick it up.


#3

Ah, that did the trick. I wasn’t aware updating works through polling the commands again. So this in getCommandInfo() worked fine:

case sc::CommandIDs::playPause:
						
	if(m_playbackOnPlay)
		result.setInfo(sc::Resources::Translate("Pause"), sc::Resources::Translate("Pause Desc"), sc::CommandCategories::general, ApplicationCommandInfo::dontTriggerVisualFeedback);
	else
		result.setInfo(sc::Resources::Translate("Play"), sc::Resources::Translate("Play Desc"), sc::CommandCategories::general, ApplicationCommandInfo::dontTriggerVisualFeedback);
			
	result.defaultKeypresses.add(juce::KeyPress(juce::KeyPress::spaceKey, juce::ModifierKeys::noModifiers, 0));

	break;

Thanks for your great support!