The Commands List Object

Commands list is a context menu that contains command buttons.

var brkSample = new TBrick();
var cmdSample = new TCommandsList();
var wndCommandsListSample = createWindow('Commands List Sample');

var onBrickClick = function() { cmdSample.show(brkSample.getX() + 20, brkSample.getY() + 20); };

var setBlue = function() { brkSample.setBackground('#0000ff'); cmdSample.hide(); };
var setGreen = function() { brkSample.setBackground('#00ff00'); cmdSample.hide(); };
var setRed = function() { brkSample.setBackground('#ff0000'); cmdSample.hide(); };

brkSample.addEvent('click', onBrickClick);
brkSample.setSize(200, 200);

cmdSample.add('blue', 'Set Color to Blue', setBlue);
cmdSample.add('green', 'Set Color to Green', setGreen);
cmdSample.add('red', 'Set Color to Red', setRed);

wndCommandsListSample.add(brkSample);
showModal(wndCommandsListSample);

In this example, when the user clicks on the brick object, the commands list shows up and the user may set the background color of the brick to blue, green, or red. When the user clicks on a command the background color is set and the commands list is hidden.


Commands list constructor takes no parameters:

var cmdSample = new TCommandsList();

Commands List Methods and Properties
Method/Property Description
add Adds command items to the list. Form:

add(commandId, commandText, callback, commandIconUrl, parentId)

Where:
  • commandId is the item identity. Tip: you may use: TUniqueId.getUniqueId() to generate identity.
  • commandText is the command title.
  • callback is the click event handler that will be called when the item is clicked.
  • commandIconUrl is the command icon URL (size 24*24).
  • parentId is the item parent identity. If the item has no parent (root item), you may leave it null or empty ''.
clear Clears command list items
disable Disables a command button by command id. Form:disable(commandId)
enable Enables a command button by command id. Form:enable(commandId)
hide Hides the commands list
setCommandCallback Sets command item click event handler. Form:
setCommandCallback(commandText, callback)
setPadding Sets command list padding between items
show Shows the command list at specific coordinates. Form: show(x, y)