Button

Button UI component that extends UIComponent class. For more methods for this component check UIComponent class.

Constructor

new Button(textopt)

Button constructor.

Parameters:
NameTypeAttributesDescription
textstring<optional>

Button text

Example
this.button1 = new Button().text("Click Me");
this.button2 = new Button("Click Me");

Classes

Button

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:
NameTypeAttributesDescription
commandstring<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.
});