This class is used for non-editable text fields (as opposed to
<inputtext>). A text field can be initalized
with text content at compile time.
<canvas height="30">
<text>Hello world!</text>
</canvas>
Text objects can also display text that is computed at runtime.
<canvas height="30">
<class name="clickClock" extends="text">
<attribute name="dayTable" value="["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]"/>
<handler name="onclick">
var now = new Date;
this.format("You clicked me at %02d:%02d:%02d on %s",
now.getHours(),
now.getMinutes(),
now.getSeconds(),
dayTable[now.getDay()]);
</handler>
</class>
<clickClock>
Click Me!
</clickClock>
</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:
canvas.maxtextheight and canvas.maxtextwidth attributes
| Name | Type (tag) | Type (js) | Default | Category |
|---|---|---|---|---|
antiAliasType
|
string | String | read/write | |
| antialias type for this text | ||||
gridFit
|
string | String | read/write | |
| Grid fit for this text | ||||
hscroll
|
Number | Number | read/write | |
| The horizontal scroll position in pixels. Default 0. You must use setAttribute('scrollevents', true) to cause this property to change. | ||||
letterspacing
|
number | Number | read/write | |
| letter-spacing for this text | ||||
lineheight
|
Number | Number | readonly | |
| The height of a line of text in the current style | ||||
maxhscroll
|
Number | Number | readonly | |
The maximum horizontal scroll position in pixels.
this.setAttribute('hscroll', this.maxhscroll) will
cause the end of content to be visible at the edge of
the view. (The rightmost content will appear at the right edge
of the view for left-to-right scripts, hence this is the pixel
position of the leftmost pixel that will appear in the view when
scrolled all the way to the right.) You must use
setAttribute('scrollevents', true) to cause this property to change.
|
||||
maxlength
|
numberExpression | Number | read/write | |
| Maximum number of characters allowed in this field | ||||
maxlines
|
Number | Number | readonly | |
| The number of lines that will fit in the current height | ||||
maxscroll
|
Number | Number | readonly | |
The maximum vertical scroll position (in lines, 1-based).
this.setAttribute('scroll', this.maxscroll) will
cause the last line of the content to be visible at the bottom of
the view (hence this is the line number of the line that will
appear at the top of the view when scrolled all the way to the
bottom). You must use setAttribute('scrollevents', true) to cause this
event to be sent.
|
||||
multiline
|
boolean | Boolean | "false" | initialize-only |
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.
|
||||
pattern
|
string | String | read/write | |
| 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]* | ||||
resize
|
booleanLiteral | Boolean | read/write | |
If true, the width of the text field will be recomputed each time
text is changed, so that the text view is exactly as wide as
the width of the widest line. Defaults to true.
|
||||
scroll
|
Number | Number | read/write | |
| The vertical scroll position (in lines, 1-based). Default 1. | ||||
scrollevents
|
Boolean | Boolean | read/write | |
| You must use setAttribute('scrollevents', true) to cause scroll events to be sent. | ||||
scrollheight
|
Number | number | readonly | |
The total height of the content in pixels.
this.setAttribute('height', this.scrollheight) is
equivalent to this.setAttribute('height', null) (for
the current content: the former will not follow content changes
as the latter does). If this.scrollheight >
this.height, this.setAttribute('yscroll',
this.height - this.scrollheight) will scroll the content
so that the bottom of the content appears in the bottom of the
view. You must use setAttribute('scrollevents', true)
to cause this property to change.
|
||||
scrollwidth
|
Number | number | readonly | |
The total width of the content in pixels.
this.setAttribute('width', this.scrollwidth) is
equivalent to this.setAttribute('width', null) (for
the current content: the former will not follow content changes
as the latter does). If this.scrollwidth >
this.width, this.setAttribute('yscroll', this.width
- this.scrollwidth) will cause the end of content to be
visible at the edge of the view. (The rightmost content will
appear at the right edge of the view for left-to-right scripts.) You must
use setAttribute('scrollevents', true) to cause this property to change.
|
||||
selectable
|
booleanLiteral | Boolean | read/write | |
| If true, the text is selectable | ||||
sharpness
|
number | Number | read/write | |
| text sharpness for this text | ||||
text
|
string | String | read/write | |
The text to display in this text field. If set to a value that is
not a string, the value will first be converted to a string as if
by String(value). To display nothing, set the value
to the empty string "".
|
||||
textalign
|
string | String | read/write | |
| text-align for this text | ||||
textdecoration
|
string | String | read/write | |
| text-decoration for this text, either 'none' or 'underline'. | ||||
textindent
|
number | Number | read/write | |
| text-indent for this text | ||||
thickness
|
number | Number | read/write | |
| text-thickness for this text | ||||
xscroll
|
Number | Number | read/write | |
| The x scroll offset of the content in pixels (a negative number specifying how many pixels the content should be scrolled horizontally). Default 0. You must use setAttribute('scrollevents', true) to cause this property to change. | ||||
yscroll
|
Number | Number | read/write | |
| The y scroll offset of the content in pixels (a negative number specifying how many pixels the content should be scrolled vertically). Default 0. You must use setAttribute('scrollevents', true) to cause this property to change. | ||||
aaactive, aadescription, aaname, aasilent, aatabindex, align, backgroundrepeat, bgcolor, cachebitmap, capabilities, clickable, clickregion, clip, context, contextmenu, cornerradius, cursor, fgcolor, focusable, focustrap, font, fontsize, fontstyle, frame, framesloadratio, hassetheight, hassetwidth, height, layout, loadratio, mask, opacity, pixellock, playing, proxyurl, resource, resourceheight, resourcewidth, rotation, shadowangle, shadowblurradius, shadowcolor, shadowdistance, showhandcursor, source, stretches, subviews, tintcolor, totalframes, unstretchedheight, unstretchedwidth, usegetbounds, valign, visibility, visible, width, x, xoffset, y, yoffset
classroot, cloneManager, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, subnodes
Methods
| addFormat() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| control | string | A control string where % indicates the conversion of the corresponding argument |
| args | [*] | arguments to be formatted according to the control string |
| addText() |
|---|
| clearText() |
|---|
| escapeText() |
|---|
| format() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| control | string | A control string where % indicates the conversion of the corresponding argument |
| args | [*] | arguments to be formatted according to the control string |
| getAntiAliasType() |
|---|
| getGridFit() |
|---|
| getSelectionPosition() |
|---|
| Returns | Type | Description |
|---|---|---|
| Number | The position of the text cursor within this textfield, 0 based. If the text cursor is not in the textfield, this method returns -1. |
| getSelectionSize() |
|---|
| Returns | Type | Description |
|---|---|---|
| Number | The length of the text selection within this textfield. If the text cursor is not in the textfield, this method returns -1. |
| getSharpness() |
|---|
| getText() |
|---|
![]() |
This method is deprecated |
|---|---|
Just use the text attribute
|
| getTextHeight() |
|---|
| getTextWidth() |
|---|
| getThickness() |
|---|
| $lzc$set_clip() |
|---|
| makeTextLink() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| str | String | The text displayed in the hyperlink. |
| value | String | The value returned when the link is clicked. |
| setAntiAliasType() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('antiAliasType', ...) instead. |
| setGridFit() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('gridFit', ...) instead. |
| setHScroll() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('hscroll', ...) instead. |
| setMultiline() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('multiline', ...) instead. |
| setResize() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('resize', ...) instead. |
| Parameter Name | Type | Description |
|---|---|---|
| val | Boolean | if true, the textfield will recompute it's width after setText() is called |
| setScroll() |
|---|
![]() |
This method is deprecated |
|---|---|
| use `setAttribute('scroll', ...)` instead |
| setSelectable() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('selectable', ...) instead. |
| setSelection() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| start | Number | The beginning of the text selection, or the position for the text cursor if no end is given. The index is 0 based. |
| end | Number | The end of the text selection. Optional. If not given, then the text cursor is positioned at the start point, but no text is selected. |
| setSharpness() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('sharpness', ...) instead. |
| setText() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('text', ...) instead. |
| setThickness() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('thickness', ...) instead. |
| setXScroll() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('xscroll', ...) instead. |
| Parameter Name | Type | Description |
|---|---|---|
| n | Number | set the left edge of the textfield to offset n pixels (n is always < 0) |
| setYScroll() |
|---|
![]() |
This method is deprecated |
|---|---|
| Use setAttribute('yscroll', ...) instead. |
| Parameter Name | Type | Description |
|---|---|---|
| n | Number | set the top line of the textfield to offset n pixels vertically (n is always < 0) |
| updateLineAttribute() |
|---|
bringToFront, containsPt, getAttributeRelative, getBounds, getColor, getColorTransform, getContextMenu, getCurrentTime, getDepthList, getDisplayObject, getID3, getMouse, getNextSelection, getPan, getPrevSelection, getProxyURL, getTotalTime, getVolume, init, isBehind, isInFrontOf, isMouseOver, measureHeight, measureWidth, play, proxyurl, releaseLayouts, searchSubviews, seek, sendAAEvent, sendBehind, sendInFrontOf, sendToBack, setAAActive, setAADescription, setAAName, setAASilent, setAATabIndex, setAccessible, setAlign, setAttributeRelative, setBGColor, setClickable, setColor, setColorTransform, setContextMenu, setCursor, setHeight, setLayout, setOpacity, setPan, setPlay, setProxyPolicy, setProxyURL, setResource, setResourceNumber, setRotation, setShowHandCursor, setSource, setValign, setVisibility, setVisible, setVolume, setWidth, setX, setXOffset, setY, setYOffset, shouldYieldFocus, stop, stretchResource, unload, updateResourceSize
animate, applyConstraint, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setData, setDatapath, setOption, setSelected, updateData
Events
onaddsubview, onbackgroundrepeat, onblur, onclick, onclickable, onclip, oncontext, oncornerradius, ondblclick, onerror, onfocus, onfont, onfontsize, onfontstyle, onframe, onframesloadratio, onheight, onkeydown, onkeyup, onlastframe, onload, onloadratio, onmousedown, onmousedragin, onmousedragout, onmouseout, onmouseover, onmousetrackout, onmousetrackover, onmousetrackup, onmouseup, onmouseupoutside, onopacity, onplay, onremovesubview, onresource, onresourceheight, onresourcewidth, onrotation, onshadowangle, onshadowblurradius, onshadowcolor, onshadowdistance, onstop, ontimeout, ontintcolor, ontotalframes, onunstretchedheight, onunstretchedwidth, onvisibility, onvisible, onwidth, onx, onxoffset, ony, onyoffset
Copyright © 2002-2009 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.