You can subclass basetree
to build a tree
control with your own look and feel. Basetree has two content areas:
item
and children
. The
item
view is where the visual component of the tree
should be placed. Any view that you want to place in the tree node
should be placed in item
. You can use
placement="item"
. The children
view is
the defaultplacement for basetree.
The following diagram demonstrates how item
and
children
are associated in tree. Since
basetree
has no visual component,
tree
is used here for demonstration
purposes.
When the basetree
expands recursively, the datapath must be
a relative reference to the dataset. If an absolute
refrence is used, the same nodes would be selected over
and over forever, resulting in and endless loop.
For example, this will hang in an endless loop:
<dataset name="navdata"> <navmenu> <section /> </navmenu> </dataset> <view x="10" y="10" layout="axis: x; spacing: 10"> <basetree width="160" height="20" datapath="navdata:/navmenu" /> </view>
It needs to be rewritten to have a relative datapath in the recursively expanding tree node.
<basetree width="160" height="20" datapath="navdata:/navmenu"> <basetree width="160" height="20" datapath="*" /> </basetree>
Example 43. Basetree subclass with echoed text node
<canvas
height
="200
">
<include
href
="base/basetree.lzx
"/>
<class
name
="echotree
" extends
="basetree
">
<view
placement
="item
" layout
="axis: x; spacing: 2
" bgcolor
="${classroot.selected ? classroot.style.selectedcolor : classroot.parent.bgcolor}
">
<handler
name
="onclick
">
classroot.changeFocus();
if (! classroot.isleaf) {
classroot.setAttribute("open", ! classroot.open);
}
</handler
>
<text
text
="${classroot.text}
" resize
="true
"/>
<text
text
="${classroot.text}
" resize
="true
"/>
</view
>
</class
>
<view
x
="20
" y
="20
" layout
="axis: x; spacing: 10
">
<echotree
>paragraph
<echotree
>sentence
<echotree
>words
<echotree
isleaf
="true
">letter
</echotree
>
<echotree
isleaf
="true
">number
</echotree
>
<echotree
isleaf
="true
">punctuation
</echotree
>
</echotree
>
</echotree
>
</echotree
>
</view
>
</canvas
>
Name (CSS property) | Type (tag) | Type (js) | Default | Category |
---|---|---|---|---|
autoscroll
|
boolean | boolean | false | read/write |
Auto scroll if tree is clipped. | ||||
closechildren
|
boolean | boolean | false | read/write |
Close all immediate children when this tree is closed. | ||||
closesiblings
|
boolean | boolean | false | read/write |
Flag to close other siblings when this tree is open. | ||||
focused
|
boolean | boolean | false | readonly |
If true, this tree is focused. | ||||
focusoverlay
|
boolean | boolean | false | read/write |
Meaningful only in root. If focusselect is false and focusoverlay is true, then focus has a visual bracket overlay over the focused tree. | ||||
focusselect
|
boolean | boolean | false | initialize-only |
Meaningful only in root. Flag to select a tree on focus. | ||||
isleaf
|
boolean | boolean | false | read/write |
If true, this basetree is a leaf node. | ||||
layout
|
expression | any | class: simplelayout; axis: y; spacing: 0 | read/write |
Layout for children. | ||||
multiselect
|
boolean | boolean | false | initialize-only |
Meaningful only in root. Whether to multiselect items. | ||||
open
|
boolean | boolean | false | read/write |
Check to see if this tree is open. | ||||
recurse
|
boolean | boolean | true | initialize-only |
Meaningful only with data replication. If true, it will recursively follow the datapath's children. | ||||
selected
|
boolean | boolean | false | read/write |
Check to see if this tree is selected. Default is false, except for the root of a tree, which its selected attribute is set to true. | ||||
showroot
|
boolean | boolean | true | initialize-only |
Meaningful only in root tree. If false, the root item is invisible and its children are displayed. | ||||
toggleselected
|
boolean | boolean | false | initialize-only |
Meaningful only in root. Flag to toggle selected nodes. | ||||
xindent
|
number | Number | 10 | read/write |
Spacing to indent trees on the x-axis. | ||||
yindent
|
number | Number | 20 | read/write |
Spacing to indent trees on the y-axis. |
doesenter, enabled, hasdefault, isdefault, style, styleable, text
aaactive, aadescription, aaname, aasilent, aatabindex, align, backgroundrepeat, bgcolor, cachebitmap, capabilities, clickable, clickregion, clip, colortransform, context, contextmenu, cornerradius, cursor, fgcolor, focusable, focustrap, font, fontsize, fontstyle, frame, framesloadratio, hasdirectionallayout, 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, xscale, y, yoffset, yscale
classroot, cloneManager, data, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, styleclass, subnodes, transition
Methods
changeFocus() |
---|
Parameter Name | Type | Description |
---|---|---|
focusedTree | Basetree | the tree to focus. If null, the current tree is focused. |
getChildClass() |
---|
getChildIds() |
---|
getChildIndex() |
---|
getDepth() |
---|
getLength() |
---|
getLocationDescription() |
---|
getRoot() |
---|
getSelection() |
---|
Returns | Type | Description |
---|---|---|
Object | if multiselect is true, an array of basetrees, else the selected basetree. If none selected, returns null. |
isRoot() |
---|
keySelect() |
---|
openChildren() |
---|
acceptValue, doEnterDown, doEnterUp, doSpaceDown, doSpaceUp, presentValue, setStyle, setTint, updateDefault
bringToFront, containsPt, getAttributeRelative, getBounds, getColor, getColorTransform, getCurrentTime, getDepthList, getDisplayObject, getID3, getMouse, getNextSelection, getPan, getPrevSelection, getProxyURL, getTotalTime, getVolume, init, isBehind, isInFrontOf, isMouseOver, measureHeight, measureWidth, play, proxyurl, searchSubviews, seek, sendAAEvent, sendBehind, sendInFrontOf, sendToBack, setAccessible, setAttributeRelative, setColor, setColorTransform, setPan, setProxyPolicy, setSource, setVolume, shouldYieldFocus, stop, unload, updateResourceSize
animate, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setOption, setSelected, updateData
Events
onaddsubview, onbackgroundrepeat, onblur, onclick, onclickable, onclip, oncontext, oncornerradius, ondblclick, onerror, onfocus, onframe, onframesloadratio, ongesture, onheight, onkeydown, onkeyup, onlastframe, onload, onloadratio, onmousedown, onmousedragin, onmousedragout, onmouseout, onmouseover, onmousetrackout, onmousetrackover, onmousetrackup, onmouseup, onmouseupoutside, onopacity, onplay, onplaying, onremovesubview, onshadowangle, onshadowblurradius, onshadowcolor, onshadowdistance, onstop, ontimeout, ontouch, onvisible, onwidth, onx, ony
Copyright © 2002-2010 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.