PDA

View Full Version : Attributes


marc
01-05-2004, 08:09 AM
Hi All
Does anyone know how to re-use attributes within a class instance?
I think I am missing something fundamental here but from what I read this should produce 2 boxes, one with the text "Box1" and the second with the text "Label".
I'm sure this is a no-brainer.
Marc

<canvas>
<simplelayout spacing="5"/>
<class name="box" height="100" width="100" bgcolor="red">
<attribute name="label" value="Label"/>
<text text="${parent.label}" />
</class>

<box label="Box1"/>
<box/>
</canvas>

antun
01-05-2004, 02:23 PM
You're right - this is a no-brainer :)

You should type your attributes when you declare them:


<canvas>
<simplelayout spacing="5"/>
<class name="box" height="100" width="100" bgcolor="red">
<attribute name="label" value="Label" type="string"/>
<text text="${parent.label}" />
</class>

<box label="Box1"/>
<box/>
</canvas>


... by default attributes are typed as "expression" which means JavaScript expression.

-Antun

arina
01-27-2005, 11:56 PM
Simple example doesn't work:



<class name="my_button" extends="basebutton">
<attribute name="align" type="token"/>

<method event="onclick">
debug.write(this.getAttribute('align'));
</method>
</class>

<my_button align="right"/>



debug output: undefined