resizestate.lzx
<library>
<class name="resizestate" extends="state">
<attribute name="__resize_xroffset" value="this.x - this.width + this.getMouse( 'x' )
" when="once"/>
<attribute name="width" value="${this.immediateparent.getMouse( 'x' )- this.__resize_xroffset}"/>
<attribute name="__resize_yroffset" value="this.y - this.height + this.getMouse( 'y' )
" when="once"/>
<attribute name="height" value="${this.immediateparent.getMouse( 'y' )- this.__resize_yroffset}"/>
<doc>
<tag name="shortdesc"><text>A standard resize behavior.</text></tag>
<text>
<p><classname>resizestate</classname> can be used to change the
width and height of a view in response to the movement of the
mouse.</p>
<p>In the example below, the <classname>resizestate</classname> tracks
differences in the mouse position from after it is applied, so the
bottom right corner of the resizing view <em>does not</em> snap to the
mouse position.</p>
<example title="Resizing a view using the mouse">
<canvas height="120">
<view bgcolor="green" width="100" height="100"
onmousedown="rs.setAttribute('applied', true)" onmouseup="rs.setAttribute('applied', false)">
<resizestate name="rs"/>
</view>
</canvas>
</example>
</text>
</doc>
</class>
</library>