command([command])
Class: Button.
Description:
Sets or gets an action command. This command is specified in event object for onAction(e => {alert(e.command);}) event handler.
Default value of action command for a Button is it's initial text.
Parameters:
| Name | Type | Description |
|---|---|---|
|
|
string |
(Optional) |
Returns:
If called without arguments, returns number value, otherwise returns this Button instance.
Type: string | Button
Examples:
const button = new Button("Activate").addTo(window).center();
button.command("Activate Motor 1");
button.onAction(e => {
alert(e.command); // shows a dialog window with a message "Activate Motor 1" when button is clicked.
});
