[Laszlo-dev] Setting constraints on a newed object

P T Withington ptw at pobox.com
Thu Jul 21 06:39:12 PDT 2005


Good to see someone is reading the documentation!  I didn't realize  
that applyConstraint was public, but it it certainly the right way to  
go (better than the way Adam and I proposed) because it will also  
take care of managing the delegates that get created so they don't  
leak, _and_ it will make sure that the constraint is executed at  
least once (which Adam and I missed, too).

Thanks Achim!

On 21 Jul 2005, at 09:20, achim bode wrote:

> hi Andrew,
>
> there is a general description on:
> http://www.laszlosystems.com/lps-2.2/docs/guide/ 
> constraints.html#d0e10373
>
> applyConstraint()
>
> The following example uses the applyConstraint() method inherited  
> from LzNode in order to create a constraint at runtime. You'll see  
> that the setConstraint method has the same effect as the simple  
> expression y=${m.y}
>
> Code Sample:
>
> <canvas>
>   <view x="250" width="20" height="20" bgcolor="red"
>         y="${m.y}"/>
>
>   <view x="300" width="20" height="20" bgcolor="blue">
>     <method name="setConstraint" event="oninit">
>       var f = function () {
>         this.setAttribute("y", m.y);
>       }
>       var d = [m, "y"];
>       this.applyConstraint("y", f, d);
>     </method>
>   </view>
>
>   <window id="m" x="10" title="Drag me" width="160" height="20"/>
> </canvas>
>
> f is a callback function that is required for the applyConstraint()  
> method.
> d is an array consisting of a pointer to a reference node, and the  
> attribute to bind to.
>
>
> Regards,
>           Achim
>
> --------------------
> Tuesday, July 19, 2005, 6:52:46 PM, you wrote:
>
> AM> What's the best way to set up constraints on a javascript-created
> AM> object?
>
> AM> e.g.   convert <LZClass height="40" width="${parent.width}" />  
> into
> AM> javascript
>
> AM>   var obj = new LZClass(this, {height: 40});
>
> AM> ... then what?
>
>
> AM> andrew
>
> AM> _______________________________________________
> AM> Laszlo-dev mailing list
> AM> Laszlo-dev at openlaszlo.org
> AM> http://www.openlaszlo.org/mailman/listinfo/laszlo-dev
>
>
> _______________________________________________
> Laszlo-dev mailing list
> Laszlo-dev at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-dev
>
>



More information about the Laszlo-dev mailing list