Name

button — The button class provides a simple pushbutton.

Synopsis

LZX: button
JavaScript: button
Type: Class
Access: public
Topic: Components.Laszlo Components
Declared in: lps/components/lz/button.lzx

Description

The button tag provides a simple button. The button is rectangular and typically displays a text label describing its action. The button adjusts to fit the label.

Example 39. Simple button

<canvas height="30">      
  <button onclick="animate('x', 100, 1000, true)">
    Move me
  </button>
</canvas>

If you need to format the text using additional tags such as b, add the text inside the button tags instead of using the text attribute.

Example 40. XHTML button

<canvas height="30">      
  <button onclick="animate('x', 100, 1000, true)">
    Move <b>me</b>
  </button>
</canvas>

A button may contain both XHTML markup, and object tags such as attribute and method.

Example 41. XHTML button

<canvas height="30">      
  <button onclick="moveHoriz(5);">
    Move <b>me</b>
    <method name="moveHoriz" args="moveAmount">
      this.setAttribute("x", this.x+moveAmount);
    </method>
  </button>
</canvas>

This is a simple rectangular button with a text label. If no height is given, the default height is used and a special resource configuration is employed which prevents the button from being able to be resized at runtime in the y-axis, but which is significantly lighter weight than the standard Button configuration.

Superclass Chain

node (LzNode) » view (LzView) » basecomponent » basebutton » button

Known Subclasses

Known Direct Subclasses: basesliderthumb, menubutton

Details

Properties (5)

focusable
<attribute name="focusable" value="true" />
public var focusable;
if true, the enter key will activate this button (call its onclick handler) if it is enclosed in a form. It will also have a visually distinct look to indicate to the user
text_padding_x
<attribute name="text_padding_x" type="number" value="11" />
public var text_padding_x : Number;
the amount of space to add horizontally when sizing button to its text. default: 11
text_padding_y
<attribute name="text_padding_y" type="number" value="4" />
public var text_padding_y : Number;
the amount of space to add vertically when sizing button to its text. default: 4
text_x
<attribute name="text_x" type="number" value="${this.width/2 - this._title.width/2}" />
public var text_x : Number;
the x position of the button text. default: centered
text_y
<attribute name="text_y" type="number" value="${this.height/2 - this._title.height/2}" />
public var text_y : Number;
the y position of the button text. default: centered

LZX Synopsis

<class name="button" extends=" basebutton ">
  <attribute name=" focusable " value="true" />
  <attribute name=" text_padding_x " type="number" value="11" />
  <attribute name=" text_padding_y " type="number" value="4" />
  <attribute name=" text_x " type="number" value="${this.width/2 - this._title.width/2}" />
  <attribute name=" text_y " type="number" value="${this.height/2 - this._title.height/2}" />
</class>

JavaScript Synopsis

public button extends  basebutton  {
  public var focusable ;
  public var text_padding_x  : Number;
  public var text_padding_y  : Number;
  public var text_x  : Number;
  public var text_y  : Number;
}