[Laszlo-user] Laszlo Code Question

P T Withington ptw at openlaszlo.org
Fri Apr 28 08:23:21 EDT 2006


Does anyone else think that this syntax is barfalicious?  Could we  
have a better way?

Is the arglist meant to be the JSON representation of the XML that  
you would have used statically?

With the advent of e4x, could we just use the XML?  Something like:

canvas.appendChild(canvas.createElement(
   <{new_class} name="first" width="100" height="100" bgcolor="blue>
     <view name="second" bgcolor="{red}" x="100" width="20"  
height="20 />
   </{new_class}>));

?

On 2006-04-28, at 00:33 EDT, Adam Wolff wrote:

> I didn't test, but I think this should be:
> new new_class(canvas, {name: "first", width: 100,
>                        height: 100, bgcolor: blue},
>               [ { name : "LzView" ,
>                   attrs: {name: "second", bgcolor: red, x: 100,
>                           width: 20, height: 20} ], true );
>
>
> A
>
>
> On Apr 27, Max Carlson wrote:
>
>> Hi,
>>
>> I can't get this code example to work correctly to demonstrate how to
>> instantiate a new class. The third argument is suppose to be for the
>> children of this instantiated class, but how do you set the parent  
>> view
>> of the children. Right now, the view "second" is appearing at the top
>> level. This occurs naturally enough because I have supplied "null" as
>> its parent argument, but canvas.first produces a "first property not
>> found" error. The small red square should appear inside the blue  
>> square
>> and be its child
>>
>> <canvas>
>>    <class name="new_class" width="100" height="100"/>
>>    <handler name="oninit">
>>       var parentview =
>>           new new_class(canvas, {name: "first", width: 100,
>>                        height: 100, bgcolor: blue},
>> [ new LzView(null, {name: "second", bgcolor: red, x: 100, width: 20,
>> height: 20})], true);
>>    </handler>
>>    <handler name="onaddsubview" args="view">
>>       if (view.name <http://view.name> == null) return;
>>       Debug.write("view = " + view.name <http://view.name>);
>>    </handler>
>> </canvas>
>>
>> _______________________________________________
>> Laszlo-user mailing list
>> Laszlo-user at openlaszlo.org
>> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
>>
> _______________________________________________
> 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