ApplicationCommandTarget in tracktion engine?

Hi, I implemented my own UIBehaviour overriding methods:

juce::ApplicationCommandManager* getApplicationCommandManager() override         { return &commandManager; }
void getAllCommands (juce::Array<juce::CommandID>& commands) override;
void getCommandInfo (juce::CommandID commandID, juce::ApplicationCommandInfo& result) override;
bool perform (const juce::ApplicationCommandTarget::InvocationInfo& info) override;

but on my mainComponent if I implement this method:

PopupMenu MainComponent::getMenuForIndex (int topLevelMenuIndex, const String& menuName);

nothing is displayed in menu selected, so I asked me if I need to inherit My UIBehaviour class with ApplicationCommandTarget and in the init of this class call commandManager.registerAllCommandsForTarget( **this** );

in Main component if I also try to print the number of command registered it prints me 0:

ApplicationCommandManager* commandManager = engine.getUIBehaviour().getApplicationCommandManager();

DBG(commandManager->getNumCommands());

how do you thought this in tracktion?

Thank you in advice!

Solved I do in this way, I inherited My UIBehaviour class with ApplicationCommandTarget and in the init of this class call commandManager.registerAllCommandsForTarget( **this** ); :slight_smile:

I think you probably want to keep your UIBehaviour subclass and ApplicationCommandTarget subclass separate.

The only reason UIBehaviour needs to return ApplicationCommandTarget is so:

  1. The AlphaTrackControlSurface can send key presses to it
  2. You may want to access your command manager via the UIBehaviour class in your UI e.g. plugins windows.

But for most cases, you won’t need to implement these if you can get direct access to your ApplicationControlManager.

1 Like

Ok Thank You! this could be the reason of this topic?