a button with multiple states, such as a toggle button
A multistatebutton is an extension of the
basebutton class to address the more general
class of buttons that can have multiple states, and where each state
has it own mouseup, mouseover, and mousedown images. Like the
basebutton class, the construction of a
multistatebutton starts with a multiframe
resource.
The example below create a play/pause button, using the following resources:
With a multistatebutton, the following must be specified explicitly:
<library>
<!-- first create the multi-frame resource and give it a name -->
<resource name="mybutton_rsrc">
<!-- State: 0 -->
<!-- first frame of state 1 = mouseup image of the button -->
<frame src="images/multistatebutton/state0-mouseup.jpg"/>
<!-- second frame of state 1 = mouseover image of the button -->
<frame src="images/multistatebutton/state0-mouseover.jpg"/>
<!-- third frame of state 1 = mousedown image of the button -->
<frame src="images/multistatebutton/state0-mousedown.jpg"/>
<!-- State: 1 -->
<!-- first frame of state 2 = mouseup image of the button -->
<frame src="images/multistatebutton/state1-mouseup.jpg"/>
<!-- second frame of state 2 = mouseover image of the button -->
<frame src="images/multistatebutton/state1-mouseover.jpg"/>
<!-- third frame of state 2 = mousedown image of the button -->
<frame src="images/multistatebutton/state1-mousedown.jpg"/>
</resource>
</library>
<canvas height="60">
<include href="multistatebutton-resources.lzx"/>
<!-- Second, assign the resource to a basebutton tag -->
<multistatebutton name="myButton" resource="mybutton_rsrc"
statenum="0" statelength="3" maxstate="1"/>
</canvas>
Now, the multistatebutton will stay in state "0" until you switch
states. This can be accomplished by calling
myButton.setStateNum(number).
<canvas height="60">
<include href="multistatebutton-resources.lzx"/>
<multistatebutton name="myButton" resource="mybutton_rsrc"
statenum="0" statelength="3" maxstate="1"
onclick="this.toggle()">
<method name="toggle">
if (this.statenum == 0) this.setStateNum(1)
else this.setStateNum(0)
</method>
</multistatebutton>
</canvas>
| Attributes | |||||
| Name | Usage | Type (Tag) | Type (JS) | Default | Category |
| maxstate | Tag & JS | number | Number | 0 | setter |
|
the largest number allowed for the value of statenum, default: 0 |
|||||
|
|
|||||
| statelength | Tag & JS | number | Number | 3 | setter |
|
the number of frames in a state, default: 3 |
|||||
|
|
|||||
| statenum | Tag & JS | number | Number | 0 | setter |
|
the current state, default: 0 |
|||||
|
|
|||||
disabledResourceNumber, downResourceNumber, maxframes, normalResourceNumber, onresourceviewcount, overResourceNumber, reference, resourceviewcount, respondtomouseout
doesenter, enabled, hasdefault, isdefault, style, styleable, text
class, classroot, cloneManager, datapath, id, ignoreAttribute, ignoreplacement, immediateparent, initstage, name, nodeLevel, onconstruct, oninit, parent, placement, subnodes
aaactive, aadescription, aaname, aasilent, aatabindex, align, bgcolor, clickable, clickregion, clip, cursor, defaultplacement, fgcolor, focusable, focustrap, font, fontsize, fontstyle, frame, framesloadratio, hassetheight, hassetwidth, height, layout, loadratio, mask, onblur, onclick, ondata, ondblclick, onfocus, onkeydown, onkeyup, onmousedown, onmouseout, onmouseover, onmouseup, onselect, opacity, options, pixellock, play, resource, resourceheight, resourcewidth, rotation, selectiontype, showhandcursor, source, stretches, subviews, totalframes, unstretchedheight, unstretchedwidth, valign, visible, width, x, xoffset, y, yoffset
| setStateLength() | ||
| multistatebutton.setStateLength(s) | ||
|
setter for the statelength attribute |
||
| Parameters | ||
| Name | Type | Desc |
| s | None | |
|
|
||
| setStateNum() | ||
| multistatebutton.setStateNum(s) | ||
|
setter for the statenum attribute |
||
| Parameters | ||
| Name | Type | Desc |
| s | None | |
|
|
||
doSpaceDown, doSpaceUp, setResourceViewCount, showDown, showOver, showUp
animate, applyConstraint, applyData, childOf, completeInstantiation, createChildren, dataBindAttribute, destroy, determinePlacement, getAttribute, getOption, getUID, lookupSourceLocator, searchImmediateSubnodes, searchSubnodes, setAttribute, setDatapath, setID, setName, setOption
addProxyPolicy, addSubview, bringToFront, construct, containsPt, getAttributeRelative, getBounds, getColor, getColorTransform, getContextMenu, getCurrentTime, getDepthList, getHeight, getID3, getMouse, getPan, getTotalTime, getVolume, getWidth, init, measureHeight, measureWidth, play, releaseLayouts, removeProxyPolicy, searchParents, searchSubviews, seek, sendBehind, sendInFrontOf, sendToBack, setAAActive, setAADescription, setAAName, setAASilent, setAATabIndex, setAlign, setAttributeRelative, setBGColor, setClickable, setColor, setColorTransform, setContextMenu, setCursor, setHeight, setLayout, setOpacity, setPan, setPlay, setResource, setResourceNumber, setRotation, setShowHandCursor, setSource, setValign, setVisible, setVolume, setWidth, setX, setY, shouldYieldFocus, stop, stretchResource, unload, updateResourceSize
| Events |
onaddsubresource, onaddsubview, onblur, onclick, ondblclick, onerror, onfocus, onframe, onheight, onlastframe, onload, onmousedown, onmousedragin, onmousedragout, onmouseout, onmouseover, onmouseup, onmouseupoutside, onopacity, onplay, onremovesubview, onstop, ontimeout, onwidth, onx, ony
Copyright © 2002-2005 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.