This property returns the command object. The control box who triggers the
CommandEvent can have a command attribute, for example, <button
command="myCommand"/>. The value of this command attribute is the id of a
command object in a command group. When the control box triggers a CommandEvent, the
action associated with the command object is executed. So if a user want to execute
a function, he can:
associate the function with a command object and assign the
command object's id to the command attribute of the control box
add a reaction for the control box and let it reacts to the CommandEvent
<commandGroup>
<command id="myCommand" action="doMyCommand();"/>
</commandGroup>
<button label="myButton1" command="myCommand" />
<button label="myButton2" on:command="onCommand();"/>
function doMyCommand()
{
shell.print("doMyCommand");
}
function onCommand()
{
shell.print("onCommand");
var eventObj = shell.currentEvent;
if (eventObj)
{
var commandObj = eventObj.command;
if (commandObj)
{
// if we disable the command object here, this button will not
// do any action anymore.
commandObj.disabled = true;
}
}
}