Name

button — The button class provides a simple pushbutton.

Synopsis

LZX: button
JavaScript: lz.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

Details

Properties (12)

buttonstate
<attribute name="buttonstate" type="number" value="1" />
private var buttonstate : Number;
1=up, 2=down, allows title to shift a but when button is depressed
doesenter
<attribute name="doesenter" value="true" />
private var doesenter;
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
height
<attribute name="height" value="${this._title.height + 2*this.text_padding_y}" />
private var height;
leftalign
<attribute name="leftalign" type="number" value="false" />
private var leftalign : Number;
maxframes
<attribute name="maxframes" value="4" />
private var maxframes;
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
titleshift
<attribute name="titleshift" type="number" value="${this.buttonstate == 1 ? 0 : 1}" />
private var titleshift : Number;
width
<attribute name="width" value="${this._title.width + 2*this.text_padding_x}" />
private var width;

Methods (5)

_applystyle()
<method name="_applystyle" args="s" />
private function _applystyle(s);
showDown()
<method name="showDown" args="sd" />
private function showDown(sd);
_showEnabled()
<method name="_showEnabled" />
private function _showEnabled();
showOver()
<method name="showOver" args="sd" />
private function showOver(sd);
showUp()
<method name="showUp" args="sd" />
private function showUp(sd);

LZX Synopsis

<class name="lz.button" extends=" lz.basebutton ">
  <attribute name=" buttonstate " type="number" value="1" />
  <attribute name=" doesenter " value="true" />
  <attribute name=" focusable " value="true" />
  <attribute name=" height " value="${this._title.height + 2*this.text_padding_y}" />
  <attribute name=" leftalign " type="number" value="false" />
  <attribute name=" maxframes " value="4" />
  <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}" />
  <attribute name=" titleshift " type="number" value="${this.buttonstate == 1 ? 0 : 1}" />
  <attribute name=" width " value="${this._title.width + 2*this.text_padding_x}" />
  <method name=" _applystyle " args="s" />
  <method name=" showDown " args="sd" />
  <method name=" _showEnabled " />
  <method name=" showOver " args="sd" />
  <method name=" showUp " args="sd" />
</class>

JavaScript Synopsis

public lz.button extends  lz.basebutton  {
  private var buttonstate  : Number;
  private var doesenter ;
  public var focusable ;
  private var height ;
  private var leftalign  : Number;
  private var maxframes ;
  public var text_padding_x  : Number;
  public var text_padding_y  : Number;
  public var text_x  : Number;
  public var text_y  : Number;
  private var titleshift  : Number;
  private var width ;
  prototype private function _applystyle (s);
  prototype private function showDown (sd);
  prototype private function _showEnabled ();
  prototype private function showOver (sd);
  prototype private function showUp (sd);
}