Name
button —
The button class provides a simple pushbutton.
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.
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" />
-
focusable
-
<attribute name="focusable" value="true" />
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}" />
-
leftalign
-
<attribute name="leftalign" type="number" value="false" />
private var leftalign : Number;
-
maxframes
-
<attribute name="maxframes" value="4" />
-
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}" />
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="
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="
showUp
" args="
sd" />
</class>