PDA

View Full Version : Moving a view under the parent view


gargidas15
03-24-2009, 06:49 AM
I am developing image cropping in Open Laszlo 4.2.0.Can anyone please help me to stop the dragging of the child view when it exceeds it's parent view.

senshi
03-24-2009, 07:28 AM
<canvas>
<view x="50" y="50" width="100" height="100" bgcolor="blue" >
<view width="25" height="25" bgcolor="red" onmousedown="this.dragger.apply()" onmouseup="this.dragger.remove()">
<dragstate name="dragger"
drag_min_x="0"
drag_min_y="0"
drag_max_x="$once{this.parent.width - this.width}"
drag_max_y="$once{this.parent.height - this.height}" />
</view>
</view>
</canvas>

gargidas15
03-25-2009, 07:10 AM
Thank you very much. It is working. can the same logic I can apply for resizing. I also want to stop the resizing of the child view when it exceeds it's parent.

senshi
03-25-2009, 10:29 AM
OpenLaszlo includes in addition to <resizestate> also <resizestatemin>, Togawa created once a <resizestateminmax> version, see here (http://laszlo.jp/wiki/index.php?CustomComponents#vef4de57).

gargidas15
03-25-2009, 08:05 PM
I tried with <resizestatemin> but it is not working. and when I'm using <resizestateminmax> the included file resizestateminmax.lzx is said to be not found. What shall I do I now?

senshi
03-26-2009, 02:21 AM
Don't know exactly what went wrong for you. Here's a simple example:


<canvas>
<!-- http://openlaszlo.org/pipermail/laszlo-dev/attachments/20060202/b468da65/resizestateminmax.obj -->
<class name="resizestateminmax" extends="state">
<!--- @keywords private -->
<attribute name="xroffset"
value="$once{this.x - this.width + this.getMouse( 'x' )}" />
<!--- @keywords private -->
<attribute name="width"
value="${Math.min(
Math.max(Math.max((this.immediateparent.getMouse( 'x' )- xroffset),0), minwidth),
Math.min(Math.max((this.immediateparent.getMouse( 'x' )- xroffset),minwidth), maxwidth))}" />

<!--- @keywords private -->
<attribute name="yroffset"
value="$once{this.y - this.height + this.getMouse( 'y' ) }" />
<!--- @keywords private -->
<attribute name="height"
value="${Math.min(
Math.max(Math.max((this.immediateparent.getMouse( 'y' )- yroffset),0), minheight),
Math.min(Math.max((this.immediateparent.getMouse( 'y' )- yroffset),minheight), maxheight))}" />
</class>

<view x="50" y="50" width="500" height="500" bgcolor="blue" >
<view width="100" height="100" bgcolor="red" onmousedown="this.dragger.apply()" onmouseup="this.dragger.remove()">
<dragstate name="dragger"
drag_min_x="0"
drag_min_y="0"
drag_max_x="${this.parent.width - this.width}"
drag_max_y="${this.parent.height - this.height}" />
<resizestateminmax name="resizer" >
<attribute name="minwidth" value="50" />
<attribute name="minheight" value="50" />
<attribute name="maxwidth" value="${this.parent.width - this.x}" />
<attribute name="maxheight" value="${this.parent.height - this.y}" />
</resizestateminmax>
<view width="25" height="25" bgcolor="green" align="right" valign="bottom" onmousedown="this.parent.resizer.apply()" onmouseup="this.parent.resizer.remove()" />
</view>
</view>
</canvas>

gargidas15
03-26-2009, 05:51 AM
Thanks. It is working now well.

hmmm
04-23-2009, 02:19 AM
hi all,

i got a big problem here.. when i deploy the website created using mywebsite.jsp.lzx, the resizestateminmax does not work..

i wonder if anyone hv done this correctly just by resizestate? Can pls share the code with me? thx!

julien.lzx
04-24-2009, 04:58 AM
Hello Hmmm,

I've been experiencing some problems with the resizestateminmax in the SWF8 runtime.
Try to compile to swf9

Working code examples:
http://forum.openlaszlo.org/showthread.php?t=13342
http://forum.openlaszlo.org/showthread.php?t=13323

If still it doesn't work send us your code.

Best regards,
Julien