Text(LzText)
出自OpenFace
目录 |
<text>
The basic text display element.
JavaScript: LzText
Extends View 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 fontsize="16">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.
See Also:
The Text Views chapter of the Guide for a discussion of how to include and manipulate text The canvas.maxtextheight and canvas.maxtextwidth attributes.
Attributes
Name Usage Type(Tag) Type(JS) Default Category
maxlength Tag & JS number Number null readonly
maximum number of characters allowed in this field default: null
multiline Tag only boolean false final
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 aor
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 Tag & JS boolean Boolean false readonly
text width automatically resizes when text is set. default: false
text Tag & JS string String setter
Attributes inherited from Node
id, name, parent, subnodes
Attributes inherited from View
align,bgcolor,clip,cloneManager,datapath,enabled,fgcolor,focusable,fontsize,frame,hassetheight,hassetwidth,height,ignorelayout,ignorex,ignorey, opacity,resource,resourceheight,resourcewidth,rotation,source,totalframes,valign,visible,width,x,y
Methods
addText()
LzText.addText(t) Appends the string to the current text in the textfield.
Parameters Name Type Desc t String The string to add
clearText()
LzText.clearText() Clears the text field (by setting its text to the empty string)
escapeText()
LzText.escapeText(ts) 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.)
Parameters Name Type Desc ts String text string to escape
getText()
LzText.getText() Returns the string represented in the text field
Returns Type Desc The string in the text field
getTextHeight()
LzText.getTextHeight() Calculates the current height of the text held by the text field.
getTextWidth()
LzText.getTextWidth() Calculates the current width of the text held by the text field.
setColor()
LzText.setColor(c) Sets the color of all the text in the field to the given hex color.
Parameters Name Type Desc c Number The color for the text -- from 0x0 (black) to 0xFFFFFF (white)
setMultiline()
LzText.setMultiline(ml) 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.
Parameters Name Type Desc ml Boolean true if the text field should allow multiple lines
setResize()
LzText.setResize(val) setResize set behavior of text field width when new text is added. LzText only (cannot be used with LzInputText).
Parameters Name Type Desc val Boolean if true, the textfield will recompute it's width after setText() is called
setText()
LzText.setText(t) setText sets the text of the field to display
Parameters Name Type Desc t String the string to which to set the text
Methods inherited from LzNode
getAttribute, setAttribute,applyConstraint
Methods inherited from LzView
destroy, getAbsoluteX, getAbsoluteY, getBGColor, getColor, getHeight, getResource, getRotation, getSource, getTotalFrames, getWidth, getX, getY, init, sendBehind, sendInFrontOf, setAlign, setBGColor, setColor, setHeight, setOpacity, setResource, setResourceNumber, setRotation, setSource, setValign, setVisible, setWidth, setX, setY, stretchResource
Events
Name Description
ontext None
Events inherited from LzNode
ondata, oninit

