[Laszlo-user] Problem with getAttributeRelative
P T Withington
ptw at openlaszlo.org
Mon Jun 19 13:13:52 EDT 2006
I suspect that getAttributeRelative is working fine, but it is too
complex for the constraint system to figure out, cf.:
http://www.openlaszlo.org/lps-latest/docs/guide/
constraints.html#d0e13313
For performance reasons also, you might want to rewrite your code and
simply have a handler in your blue view to update its position and
dimensions when the canvas changes size. Something like:
<handler name="onwidth" reference="canvas"
method="updateDimensions" />
<handler name="onheight" reference="canvas"
method="updateDimensions" />
<method name="updateDimensions">
width=whiteSquare.getAttributeRelative('width',canvas);
height=whiteSquare.getAttributeRelative('height',canvas);
x=whiteSquare.getAttributeRelative('x',canvas);
y=whiteSquare.getAttributeRelative('y',canvas)}"
</method>
This will result in many fewer dependencies being generated and
achieve the same effect much more efficiently.
On 2006-06-18, at 20:23 EDT, Mark Engelberg wrote:
> getAttributeRelative does not seem to work for attributes 'x' and 'y'
> for views nested two deep inside of something stretchy.
>
> Consider this example:
>
> <canvas height="100%" width="100%">
> <view bgcolor="red" height="${parent.height}" width="${parent.width}"
> stretches="both">
> <view bgcolor="yellow" width="25" height="25" x="25" y="25">
> <view id="whiteSquare" bgcolor="white" width="20" height="20"
> x="5" y="5"/>
> </view>
> </view>
> <view bgcolor="blue"
> width="${whiteSquare.getAttributeRelative('width',canvas)}"
> height="${whiteSquare.getAttributeRelative('height',canvas)}"
> x="${whiteSquare.getAttributeRelative('x',canvas)}"
> y="${whiteSquare.getAttributeRelative('y',canvas)}"/>
> </canvas>
>
> If my understanding of getAttributeRelative is correct, the blue
> square should perfectly cover the white square as you resize the
> canvas. But it does not. The width and height properly match, but
> the x and y do not.
>
> When the white square is nested only one deep (i.e., remove the yellow
> square that it is inside of in the above example), it works fine.
>
> Is this a Laszlo bug, or am I doing something wrong?
>
> Thanks,
>
> Mark
> _______________________________________________
> Laszlo-user mailing list
> Laszlo-user at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
More information about the Laszlo-user
mailing list