ApplicationCommand Registration - note


It seems to have something unright in the Juce sources jassert, for ApplicationCommand registration :

In juce_ApplicationCommandManager.cpp :

void ApplicationCommandManager::registerCommand (const ApplicationCommandInfo& newCommand)
[b]// zero isn’t a valid command ID!
jassert (newCommand.commandID != 0);

// the name isn't optional!
jassert (newCommand.shortName.isNotEmpty());

if (getCommandForID (newCommand.commandID) == 0)
ApplicationCommandInfo* const newInfo = new ApplicationCommandInfo (newCommand);
newInfo->flags &= ~ApplicationCommandInfo::isTicked;
commands.add (newInfo);

    keyMappings->resetToDefaultMapping (newCommand.commandID);

    // trying to re-register the same command with different parameters?
    jassert (newCommand.shortName == getCommandForID (newCommand.commandID)->shortName
              && (newCommand.description == getCommandForID (newCommand.commandID)->description || newCommand.description.isEmpty())
              && newCommand.categoryName == getCommandForID (newCommand.commandID)->categoryName
              && newCommand.defaultKeypresses == getCommandForID (newCommand.commandID)->defaultKeypresses
              && (newCommand.flags & (ApplicationCommandInfo::wantsKeyUpDownCallbacks | ApplicationCommandInfo::hiddenFromKeyEditor | ApplicationCommandInfo::readOnlyInKeyEditor))
                   == (getCommandForID (newCommand.commandID)->flags & (ApplicationCommandInfo::wantsKeyUpDownCallbacks | ApplicationCommandInfo::hiddenFromKeyEditor | ApplicationCommandInfo::readOnlyInKeyEditor)));


void ApplicationCommandManager::registerAllCommandsForTarget (ApplicationCommandTarget* target)
if (target != 0)
Array commandIDs;
target->getAllCommands (commandIDs);

    for (int i = 0; i < commandIDs.size(); ++i)
        ApplicationCommandInfo info (commandIDs.getUnchecked(i));
        target->getCommandInfo (info.commandID, info);

        registerCommand (info);[/b]


I get jassert note in console, cause “info” has an empty short name. But how possible to set a shortname for infos, in such a code design ?


It’s quite helpfully telling you that you haven’t supplied a name - why on earth would you think that’s a bug in the juce code?

I fail to see what you’re not understanding. ApplicationCommandInfo::setInfo is obviously the way to set the name, just like all the example code does…