Name

alert — A window.

Synopsis

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

Description

The window tag creates a floating view that may be moved and optionally resized by the user. Set the closeable attribute to true in order to show a window close button.

              <canvas height="250">
              <window x="10" y="10" width="300" height="200"
              title="my window"
              resizable="true" closeable="true">
              <text>Hello</text>
              </window>
              </canvas>
            

Views placed within a window tag will be placed inside the smaller content area within the window. Because of this, you will often want to constrain to the dimensions of the content area, rather than to the window dimensions. To do this, tags placed within a window can use the immediateparent property rather than the parent property.

Example 38. Sizing to the content area

              <canvas height="150">
              <window x="10" y="10" width="200" height="100"
              resizable="true">
              <button width="${immediateparent.width}"
              height="${immediateparent.height}">
              This is a really big button
              </button>
              </window>
              </canvas>
            

Superclass Chain

node (LzNode) » view (LzView) » basecomponent » basewindow » windowpanel » modaldialog » alert

Known Subclasses

Details

Properties (7)

button1
<attribute name="button1" type="string" value="OK" />
public var button1 : String;
Alert shows only this button, if button2 isn't set. Default: "OK". You may specify a different string to change the text of the button.
button2
<attribute name="button2" type="string" value="" />
public var button2 : String;
If a string is set for this attribute, a second button will be shown to the left of the first with this text.
maxtextwidth
<attribute name="maxtextwidth" value="${Math.round(parent.width/3) - inset_left - inset_right - content_inset_left - content_inset_right}" />
public var maxtextwidth;
The max length of a line of text before it wraps. Default: 1/3 of the parent's width - width of window dressing and margin.
minwidth
<attribute name="minwidth" value="$once{button2 == '' ? 100 : 170}" />
public final var minwidth;
Minimum width for the alert. Default: 100 for a 1 button alert, 170 for a 2 button alert.
result
<attribute name="result" value="null" />
public var result;
After the alert is closed, this is set to true if button1 ("OK") is pressed or false if button2 is pressed. You can check for the result value using the onresult event.
text_x
<attribute name="text_x" type="number" value="0" />
public var text_x : Number;
The x position of the button text. Default: 0 (left).
text_y
<attribute name="text_y" type="number" value="0" />
public var text_y : Number;
The y position of the button text. Default: 0 (top).

Methods (2)

close()
<method name="close" args="res" />
public function close(res : Boolean);
Closes the alert window. This method is used by the alert button(s). If button1 is clicked, close is passed a true value. If button2 is clicked, close is passed a false value.
open()
<method name="open" />
public function open();
Opens the alert window.

Events (1)

onresult
<attribute name="onresult" />
public event onresult;
This event is sent when a button is pressed. Use this to check the result value.

LZX Synopsis

<class name="alert" extends=" modaldialog ">
  <attribute name=" button1 " type="string" value="OK" />
  <attribute name=" button2 " type="string" value="" />
  <attribute name=" maxtextwidth " value="${Math.round(parent.width/3) - inset_left - inset_right - content_inset_left - content_inset_right}" />
  <attribute name=" minwidth " value="$once{button2 == '' ? 100 : 170}" />
  <attribute name=" result " value="null" />
  <attribute name=" text_x " type="number" value="0" />
  <attribute name=" text_y " type="number" value="0" />
  <method name=" close " args="res" />
  <event name=" onresult " />
  <method name=" open " />
</class>

JavaScript Synopsis

public alert extends  modaldialog  {
  public var button1  : String;
  public var button2  : String;
  public var maxtextwidth ;
  public final var minwidth ;
  public var result ;
  public var text_x  : Number;
  public var text_y  : Number;
  prototype public function close (res : Boolean);
  prototype public event onresult ;
  prototype public function open ();
}