ApplicationCommandManager questions


I’m having a little difficulty in understanding how to correctly use the ApplicationCommandManager. I have a main Document window which inherits from MenuBarModel and ApplicationCommandTarget. I have an ApplicationCommandManager object that is a member of my main DocumentWindow class. When calling registerAllCommandsForTarget() I pass my main document window as the target. This all works fine and I can use keyboard shortcuts to call any of my menu commands. My main content component is a type of text editor and it has a toolbar component. I would like for example if the ‘new’ toolbar button would evoke the NewFile() member of my DocumentWindow class. It’s here that I get confused. How can I get my my main content component to send commands to my main window class? Every time I think about it I come up with what I think is the solution only to hit a snag along the way!



(I have to admit I also find it a bit confusing…)


The toolbar class has a Toolbar::getItemComponent, this returns a pointer to a “ToolbarItemComponent”, a “ToolbarItemComponent” is a Button, you can call setCommandToTrigger on this returned pointer and pass it a pointer to your command manager, and the command id to trigger.


or you can set the command to trigger when you create each toolbar item in your toolbar factory…

You’ll need a to create a method to get a pointer to the command manager in your document window. Why not declare the command manager to be a global variable, you’re only going to have one command manager.


With your suggestions I managed to get it working. Thanks again.