The <view> is the most basic viewable element in an
OpenLaszlo application. Anything that is displayed on the canvas is a view
or extends the view class. A view is a rectangle, which can be visible or invisible, and which can contain other views or
display "resources" such as images,
.swf files, or other supported media. One view controls one
displayable resource. The view system is strictly hierarchical; that is, each view has
a single parent but can have multiple children.
The following code shows one view nested inside another:
<canvas height="50" width="500">
<view width="50" height="50" bgcolor="red">
<view width="30" height="30" bgcolor="blue"/>
</view>
</canvas>
LzView extends <node>,
which is the fundamental abstract class of LZX.
For an introduction to views see the Laszlo tutorials, particularly OpenLaszlo Basics and Introduction to Views. For a more rigorous explanation of views see the Application Developer's Guide, particularly the Views chapter.
| Name | Type (tag) | Type (js) | Default | Category |
|---|---|---|---|---|
aaactive
|
boolean | Boolean | read/write | |
| Activate/inactivate children for accessibility | ||||
aadescription
|
string | String | read/write | |
| Set accessibility description | ||||
aaname
|
string | String | read/write | |
| Set accessibility name | ||||
aasilent
|
boolean | Boolean | read/write | |
| Set accessibility silencing/unsilencing | ||||
aatabindex
|
number | Number | read/write | |
| Set accessibility tab order | ||||
align
|
"left" | "center" | "right" | constraint | String | "left" | initialize-only |
bgcolor
|
color | color | read/write | |
| The color of background of this view. Null if there is no bgcolor. A number from 0 - 0xFFFFFF. | ||||
cachebitmap
|
boolean | Boolean | false | read/write |
| A value of true means that this view's bitmap will be cached, if available. | ||||
clickable
|
boolean | Boolean | read/write | |
| If true, this view intercepts click events; otherwise they are passed to its container. This defaults to true if the view defines a mouse event handler or a cursor. | ||||
clickregion
|
string | String | read/write | |
| Setting to a vector-based resource changes the clickable hotspot for the mouse. Check capabilities.clickregion before using to avoid debugger warnings. | ||||
clip
|
boolean | Boolean | false | initialize-only |
| Clip the view's contents to its size. | ||||
cursor
|
token | String | read/write | |
| The cursor to display when the mouse is over this view. Any resource can be used as a cursor. This attribute can be set for any view with clickable=true, or any view whose class defaults clickable to true. | ||||
fgcolor
|
color | color | read/write | |
| A color to use to render object that appears inside this view, which includes any vector or bitmap art in the view's resource and any contained views. | ||||
focusable
|
boolean | Boolean | readonly | |
| If true, this view will receive focus events. See focus manager (LzFocus) for more details. | ||||
focustrap
|
boolean | Boolean | read/write | |
| If true, this view "traps" the focus, for example in a window or dialog. See focus manager (LzFocus) for more details. | ||||
font
|
string | String | read/write | |
The font to use for any <text> or <inputtext> elements that
appear inside this view. Like all the font properties
(fontstyle and fontsize too) these
properties cascade down the view hierarchy until a new value is
specified. When the font attributes are modified at runtime,
using JavaScript, the font is changed for the view itself, not
for any of its subviews.
|
||||
fontsize
|
size | String | read/write | |
| Pixel size to use to render text which appears inside this view. The default is 8. | ||||
fontstyle
|
string | String | read/write | |
| The style to use to render text fields that appear inside of this view. One of "plain", "bold" , "italic" or "bolditalic". | ||||
frame
|
numberExpression | Number | "1" | read/write |
If this view has a multi-frame resource, this allows setting which
resource frame is displayed. Defaults to the first frame (1).
See also the resource
attribute. Setting this attribute will change the frame that is
being displayed by the resource associated with this view. The
first frame of the resource is frame 1. Setting a view's
'donttrackplay' option to true will allow the view's resource to
play without updating the value of the view's frame property. This
can save CPU usage in cases where the application doesn't need to
know what frame the resource is showing while it is playing.
|
||||
framesloadratio
|
Number | readonly | ||
| For views whose resource is loaded at runtime, the ratio of the loaded frames to the total frames. This is a number between zero and 1. | ||||
hassetheight
|
Boolean | readonly | ||
| If true, then setWidth() has been called on this view, and the view will not be sized to its contents. | ||||
hassetwidth
|
Boolean | readonly | ||
| If true, then setHeight() has been called on this view, and the view will not be sized to its contents. | ||||
height
|
sizeExpression | Number | read/write | |
| The height of the view | ||||
layout
|
css | Object | read/write | |
A CSS property when declared in the tag: value sequence of layout
parameters, which are used to create a layout that is attached to
this view. If there is a class property, it names the class of the
layout; otherwise <simplelayout> is used.
Examples:
layout="axis: x", layout="class: constantlayout",
layout="axis: y", layout="axis: x; spacing: 5".
|
||||
loadratio
|
Number | readonly | ||
| For views whose resource is loaded at runtime, ratio of the loaded bytes to the total bytes. This is a number between zero and 1. | ||||
mask
|
LzView | readonly | ||
| Reference to closest masked view in the hierarchy at or above this one | ||||
opacity
|
Number | Number | "1.0" | read/write |
The opacity of the view's contents. 1.0 is opaque; 0.0 is
totally transparent (invisible).
|
||||
pixellock
|
booleanLiteral | Boolean | read/write | |
| The view system supports sub-pixel positioning to enable smooth animation. This may be turned off to make the view snap to a pixel boundary by setting pixellock to true. | ||||
playing
|
boolean | Boolean | readonly | |
| If true, this view is currently playing. | ||||
proxyurl
|
expression | any | function | read/write |
The url of the proxy server, if the app is running in proxied mode.
proxyurl can be null, a URL string, or a function.
|
||||
resource
|
string | String | read/write | |
A resource that is presented in the background of this view. The
value can be either the name of a resource defined with the
resource tag, a URL, or a pathname. If the value is a URL,
the resource is requested when the view is displayed. If it's a
pathname, the file named by the pathname is compiled into the
application, and attached to this view.
|
||||
resourceheight
|
number | Number | readonly | |
| The height of the resource that this view attached | ||||
resourcewidth
|
number | Number | readonly | |
| The width of the resource that this view attached | ||||
rotation
|
numberExpression | Number | "0" | read/write |
| The rotation value for the view (in degrees). Value may be less than zero or greater than 360. | ||||
showhandcursor
|
boolean | Boolean | read/write | |
| Show or hide the hand cursor for this view, if clickable | ||||
source
|
string | String | read/write | |
| The URL from which to load the resource for this view. If this attribute is set, the media for the view is loaded at runtime. | ||||
stretches
|
"width" | "height" | "both" | String | "none" | read/write |
Setting stretches causes a view to change its
coordinate space so that everything it contains (resources and
other views) fit exactly into the view's width and/or height. The
default for this property is "none". This is used to resize a
view's contents by setting its width and/or height.
|
||||
subviews
|
[LzView] | readonly | ||
| An array of the subviews that are children of this view. This is initialized to an empty array for views that have no subviews. | ||||
totalframes
|
Number | readonly | ||
| The total number of frames for this view's resource. | ||||
unstretchedheight
|
Number | readonly | ||
| If stretches is not set to none, the height that this view would be if it weren't stretched. This attribute can be used to scale a view by a percentage of its original size, or to determine the aspect ratio for a view. | ||||
unstretchedwidth
|
Number | readonly | ||
| If stretches is not set to none, the width that this view would be if it weren't stretched. This attribute can be used to scale a view by a percentage of its original size, or to determine the aspect ratio for a view. | ||||
valign
|
"top" | "middle" | "bottom" | constraint | String | "top" | read/write |
| Creates a constraint on the view's y position which is a function of its height and its parent's height. The default for this is "top". | ||||
visibility
|
string | String | "collapse" | read/write |
| A value of "visible" means that this view is shown. A value of "hidden" means that this view is hidden. Setting this attribute to "collapse" means that the runtime will hide this view when: its opacity is zero, it has a datapath that does not match a node, or it is loading its media. In this case, the the value of the 'visible' attribute of the view will reflect the view's current visible state. | ||||
visible
|
boolean | Boolean | "true" | read/write |
| A value of true means that this view is shown. A value of false means that this view is hidden. Note that an otherwise clickable view that is not visible will have no click region and will not be clickable. | ||||
width
|
sizeExpression | Number | read/write | |
| The width of the view | ||||
x
|
numberExpression | Number | "0" | read/write |
| The horizontal offset of this view's upper left corner from the upper left corner of its container. | ||||
xoffset
|
numberExpression | Number | "0" | read/write |
| Specifies a translation point for drawing of this view. If the xoffset is set, then rotation and x position will be calculated by first adding the xoffset. | ||||
y
|
numberExpression | Number | "0" | read/write |
| The vertical offset of this view's upper left corner from the upper left corner of its container | ||||
yoffset
|
numberExpression | Number | "0" | read/write |
| Specifies a translation point for drawing of this view. If the yoffset is set, then rotation and y position will be calculated by first adding the yoffset. | ||||
classroot, cloneManager, datapath, defaultplacement, id, ignoreplacement, immediateparent, initstage, name, nodeLevel, options, parent, placement, subnodes
Methods
| bringToFront() |
|---|
| containsPt() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| x | Number | an x value relative to the this view's coordinates |
| y | Number | an y value relative to the this view's coordinates |
| getAttributeRelative() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| prop | String | a string specifying the property to return. known properties are: x, y, width, and height |
| refView | LzView | the reference view for the transformation |
| getBounds() |
|---|
| Returns | Type | Description |
|---|---|---|
| Object | An object with x, y, width, height, xoffset and yoffset properties that describes the bounding box of the view. |
| getColor() |
|---|
| getColorTransform() (swf8) |
|---|
| getContextMenu() |
|---|
| getCurrentTime() |
|---|
| Returns | Type | Description |
|---|---|---|
| Number | The number of seconds of media between the current frame and the first frame |
| getDepthList() |
|---|
| getID3() |
|---|
| getMouse() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| xory | String | Which axis ("x" | "y") to return. If null returns both axes. |
| Returns | Type | Description |
|---|---|---|
| Number | The position of the mouse relative to this
view along the specified axis. If both axes are requsted returns
{x: Number, y: Number}.
|
| getNextSelection() |
|---|
| getPan() |
|---|
| getPrevSelection() |
|---|
| getProxyURL() |
|---|
| getTotalTime() |
|---|
| getVolume() |
|---|
| init() |
|---|
LzNode.init()
for more.
| measureHeight() |
|---|
| measureWidth() |
|---|
| play() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| f | Integer | If defined, begin playing at the given frame. Otherwise, begin playing at the current frame. |
| rel | Boolean | If true, f is relative to the current frame. Otherwise f is relative to the beginning of the resource. |
| releaseLayouts() |
|---|
| searchSubviews() |
|---|
| Returns | Type | Description |
|---|---|---|
| LzView | the first subview whose property prop is set to val 'val' or null
if none is found
|
| seek() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| secs | Integer | Number of seconds to skip forward or backward (if negative) |
| sendBehind() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| v | LzView | The view this view should go in front of. If the passed view is null or not a sibling, the method has no effect. |
| sendInFrontOf() |
|---|
| Parameter Name | Type | Description |
|---|---|---|
| v | LzView | The view this view should go in front of. If the passed view is null or not a sibling, the method has no effect. |
| sendToBack() |
|---|
| setAAActive() |
|---|