Name

text (LzText) — The basic text display element.

Synopsis

LZX: text
JavaScript: LzText
Type: Class
Access: public
Topic: LFC.Text
Declared in: WEB-INF/lps/lfc/views/LzText.lzs

Description

This class is used for non-editable text fields (as opposed to tagname inputtext. A text field can be initalized with text content at compile time.

 
 <canvas height="30">
   <text>Hello world!</text>
 </canvas>
 

Note that certain attributes on text objects, such as opacity and rotation, only work on embedded fonts. They do not work on client fonts (also called platform fonts, native fonts, platform fonts, etc). See the Developer's Guide for details.

Superclass Chain

node (LzNode) » view (LzView) » text (LzText)

Known Subclasses

Known Direct Subclasses: inputtext (LzInputText)

Details

Static Properties (1)

escapeChars
static public var escapeChars = { ... };

Initial Attributes (9)

Initial Attributes are given as attributes in LZX but are not generally available as properties in JavaScript.

font
<attribute name="font" type="string" />
fontsize
<attribute name="fontsize" type="number" />
fontstyle
<attribute name="fontstyle" type="string" />
maxlength
<attribute name="maxlength" type="number" />
maximum number of characters allowed in this field default: null
multiline
<attribute name="multiline" type="boolean" />
password
<attribute name="password" type="boolean" />
pattern
<attribute name="pattern" type="string" />
regexp describing set of characters allowed in this field Restrict the characters that can be entered to a pattern specified by a regular expression. Currently only the expression [ ]* enclosing a set of characters or character ranges, preceded by an optional "^", is supported. examples: [0-9]* , [a-zA-Z0-9]*, [^0-9]* default: null width and height are virtual properties -- they have setters and getters, but the actual state is stored in the text sprite. They are documented in the superclass, LzView, as well. height: The height of the text field. A Number. If unspecified, then the height of the text field will be set by default to enclose the initial text value. width: The width of the text field. A Number. If width is not explicitly supplied, the text field will by default be sized to fit the width of the initial text value.
resize
<attribute name="resize" type="boolean" />
text
<attribute name="text" type="string" />

Properties (4)

colorstring
<attribute name="colorstring" />
public var colorstring = #000000;
multiline
<attribute name="multiline" type="boolean" value=""false"" />
public final var multiline : Boolean;
If true, the lines of text are wrapped to fit within the text width. (The name multiline is a misnomer. Unwrapped text can be multiple lines if it contains a <br /> or <p> element, or a line break within a <pre> element. This attribute defaults to true if width and height are explicitly specified. If you set multiline=true, you probably want to explicitly a width for the text also; if multiline=true and you do not specify a width, the system will pick an arbitrary width (100 pixels at the moment). When multiline=true, the text is automatially re-wrapped whenever the content is modified by calls to setText, or whenever the width of the text view is modified.
resize
<attribute name="resize" type="booleanLiteral" />
public var resize : BooleanLiteral = true;
If true, the width of the text field will be recomputed each time setText() is called, so that the text view is exactly as wide as the width of the widest line. Defaults to true.
text
<attribute name="text" type="string" />
public var text : String;
The text to display in this text field.

Setters (1)

Setters for virtual properties, to be used with setAttribute. A setter may or may not have a corresponding getter method; consult the Methods list in this section.

selectable
If true, the text is selectable

Methods (18)

addText()
<method name="addText" args="t" />
public function addText(t : String);
Appends the string to the current text in the textfield.
clearText()
<method name="clearText" />
public function clearText();
Clears the text field (by setting its text to the empty string)
escapeText()
<method name="escapeText" args="ts" />
public function escapeText(ts : String);
Returns an escaped version of the string if called with no args. If called with a string argument, returns an escaped version of that string (escaped here means markup-escaped, hot http escaped.)
getSelectionPosition()
<method name="getSelectionPosition" />
public function getSelectionPosition() : Number;
Returns the position of the text cursor within this object. If the text cursor is not inside this object, then the method returns -1.
getSelectionSize()
<method name="getSelectionSize" />
public function getSelectionSize() : Number;
Returns the length of the text selection in within this object. If the text cursor is not inside this object, then the method returns -1.
getText()
<method name="getText" />
public function getText();
Returns the string represented in the text field @return: The string in the text field
getTextHeight()
<method name="getTextHeight" />
public function getTextHeight();
Calculates the current height of the text held by the text field.
getTextWidth()
<method name="getTextWidth" />
public function getTextWidth();
Calculates the current width of the text held by the text field.
init()
<method name="init" />
public function init();
setHScroll()
<method name="setHScroll" args="s" />
public function setHScroll(s);
setMultiline()
<method name="setMultiline" args="ml" />
public function setMultiline(ml : Boolean);
Sets whether or not the textfield wraps. If false, only a single line of text will appear and extra lines will be trucated if the text is set with multiple lines.
setResize()
<method name="setResize" args="val" />
public function setResize(val : Boolean);
setResize set behavior of text field width when new text is added. LzText only (cannot be used with LzInputText).
setScroll()
<method name="setScroll" args="s" />
public function setScroll(s);
setSelectable()
<method name="setSelectable" args="isSel" />
public function setSelectable(isSel : Boolean);
Sets the selectability (with Ibeam cursor) of the text field
setSelection()
<method name="setSelection" args="start, end" />
public function setSelection(start : Number, end : Number);
Positions the text selection within the text field. If this object does not already have the focus, this has the ancillary effect of giving it the focus.
setText()
<method name="setText" args="t" />
public function setText(t : String);
setText sets the text of the field to display
setXScroll()
<method name="setXScroll" args="n" />
public function setXScroll(n : Number);
Set the x scroll position of the textfield.
setYScroll()
<method name="setYScroll" args="n" />
public function setYScroll(n : Number);
Set the y scroll position of the textfield.

Events (5)

onmaxlength
<attribute name="onmaxlength" />
public event onmaxlength;
onmaxscroll
<attribute name="onmaxscroll" />
public event onmaxscroll;
onpattern
<attribute name="onpattern" />
public event onpattern;
onscroll
<attribute name="onscroll" />
public event onscroll;
ontext
<attribute name="ontext" />
public event ontext;
Sent whenever the text in the field changes.

LZX Synopsis

<class name="LzText" extends=" LzView ">
  <attribute name=" colorstring " />
  <attribute name=" multiline " type="boolean" value=""false"" />
  <attribute name=" resize " type="booleanLiteral" />
  <attribute name=" text " type="string" />
  <method name=" addText " args="t" />
  <method name=" clearText " />
  <method name=" escapeText " args="ts" />
  <method name=" getSelectionPosition " />
  <method name=" getSelectionSize " />
  <method name=" getText " />
  <method name=" getTextHeight " />
  <method name=" getTextWidth " />
  <method name=" init " />
  <event name=" onmaxlength " />
  <event name=" onmaxscroll " />
  <event name=" onpattern " />
  <event name=" onscroll " />
  <event name=" ontext " />
  <method name=" setHScroll " args="s" />
  <method name=" setMultiline " args="ml" />
  <method name=" setResize " args="val" />
  <method name=" setScroll " args="s" />
  <method name=" setSelectable " args="isSel" />
  <method name=" setSelection " args="start, end" />
  <method name=" setText " args="t" />
  <method name=" setXScroll " args="n" />
  <method name=" setYScroll " args="n" />
</class>

JavaScript Synopsis

public LzText extends  LzView  {
  static public var escapeChars  = { ... };
  public var colorstring  = #000000;
  public final var multiline  : Boolean;
  public var resize  : BooleanLiteral = true;
  public var text  : String;
  prototype public function addText (t : String);
  prototype public function clearText ();
  prototype public function escapeText (ts : String);
  prototype public function getSelectionPosition () : Number;
  prototype public function getSelectionSize () : Number;
  prototype public function getText ();
  prototype public function getTextHeight ();
  prototype public function getTextWidth ();
  prototype public function init ();
  prototype public event onmaxlength ;
  prototype public event onmaxscroll ;
  prototype public event onpattern ;
  prototype public event onscroll ;
  prototype public event ontext ;
  prototype public function setHScroll (s);
  prototype public function setMultiline (ml : Boolean);
  prototype public function setResize (val : Boolean);
  prototype public function setScroll (s);
  prototype public function setSelectable (isSel : Boolean);
  prototype public function setSelection (start : Number, end : Number);
  prototype public function setText (t : String);
  prototype public function setXScroll (n : Number);
  prototype public function setYScroll (n : Number);
}