Constructor
new Button(textopt)
Button constructor.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
text | string | <optional> | Button text |
Example
this.button1 = new Button().text("Click Me");
this.button2 = new Button("Click Me");Classes
Members
(readonly) iconSize :Object|undefined
Returns current size of an icon, or undefined when no icon has been set or icon failed to load.
Type:
- Object |
undefined
Methods
command(commandopt) → {string|Button}
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 | Attributes | Description |
|---|---|---|---|
command | string | <optional> | (Optional) |
Returns:
If called without arguments, returns number value, otherwise returns this Button instance.
- Type:
- string |
Button
Example
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.
});