Expand my Community achievements bar.

SOLVED

Creating Custom Toolbar Commands

Avatar

Level 2

Hey everyone, I'm trying to add some custom commands to the toolbar, like the redo/undo/delete commands.  So far, I've extended the sharedwhiteboard and canvas, as well as added a class called RCGlowShapes extending WBCommandBase.  In my custom canvas, I've added a function as well, which creates a new instance of the RCGlowShapes command and adds it to the command manager. 

My question is this: when I add a custom command to the toolbar like this:

                         var glowTool:WBShapeToolBarDescriptor = new WBShapeToolBarDescriptor(WBShapeToolBarDescriptor.COMMAND);

                         glowTool.toolTip = "Glow Chip";

                         glowTool.command = "glow";

                         glowTool.icon = ICON_EIHEAD;

                         defaultToolBar.addCustomShapeToToolBar(glowTool);

how can I connect this button to the function in my extended WBCanvas?  Clearly the 'command' property has something to do with it.  What exactly is the command property of the WBShapeToolBarDescriptor doing?  The source says

/**

* The command that would be dispatched by the toolBar. Used if the type is WBShapeToolBarDescriptor.COMMAND

*/

I'm trying to find where in the source the undo/redo/erase commands are linked to their respective functions, like WBRemoveShapes, but I haven't had any luck...

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

You can do this.

// Get your WhiteBoard toolBar

toolBar.addEventListener(WBToolBarEvent.TOOL_BAR_CLICK,
glow)

protected function glow(p_evt:WBToolBarEvent):void
{
          if (p_evt.
item.command == "glow") {
               //Your operations
          }
}

Thanks

Arun

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

Hi,

You can do this.

// Get your WhiteBoard toolBar

toolBar.addEventListener(WBToolBarEvent.TOOL_BAR_CLICK,
glow)

protected function glow(p_evt:WBToolBarEvent):void
{
          if (p_evt.
item.command == "glow") {
               //Your operations
          }
}

Thanks

Arun