sfarrow
07-17-2003, 05:03 AM
We have been putting together our own version of a combobox component and have encountered a problem with layouts as they apply to the dropdown view of the component. Here are a couple examples to illustrate the problem.
In this first example, clicking on the red box presents a green dropdown. Clicking again dismisses it. The green dropdown view has been told to ignore layouts and as such overlaps the blue view as expected. All is good!
<view name="spike1" x="0" >
<simplelayout spacing="2"/>
<view width="200" height="25" bgcolor="yellow" />
<view name="red" width="200" height="25"
bgcolor="red" clickable="true">
<method event="onclick">
canvas.spike1.green.bringToFront();
canvas.spike1.green.setHeight(
canvas.spike1.green.getHeight() == 0 ? 80 : 0 );
</method>
</view>
<view name="green"
y="canvas.spike1.red.y+canvas.spike1.red.height"
width="200" height="0" bgcolor="green"
options="ignorelayout"/>
<view width="200" height="25" bgcolor="blue" />
</view>
I now take the red view and the green dropdown view and wrap them in a class as I move toward creating a reusable component. Clicking on the red view now inserts the green view in the layout and pushes the blue view down to accommodate it. Not what I was hoping for.
<class name="dropdown">
<view name="red" width="200" height="25"
bgcolor="red" clickable="true">
<method event="onclick">
classroot.green.bringToFront();
classroot.green.setHeight(
classroot.green.getHeight() == 0 ? 80 : 0 );
</method>
</view>
<view name="green"
y="classroot.red.y+classroot.red.height"
width="200" height="0" bgcolor="green"
options="ignorelayout"/>
</class>
<view name="spike2" x="250">
<simplelayout spacing="2"/>
<view width="200" height="25" bgcolor="yellow" />
<dropdown />
<view width="200" height="25" bgcolor="blue" />
</view>
Is there any way to get the class to behave in the same way as the non-class version and still retain the encapsulation required for a component?
Thanks.
In this first example, clicking on the red box presents a green dropdown. Clicking again dismisses it. The green dropdown view has been told to ignore layouts and as such overlaps the blue view as expected. All is good!
<view name="spike1" x="0" >
<simplelayout spacing="2"/>
<view width="200" height="25" bgcolor="yellow" />
<view name="red" width="200" height="25"
bgcolor="red" clickable="true">
<method event="onclick">
canvas.spike1.green.bringToFront();
canvas.spike1.green.setHeight(
canvas.spike1.green.getHeight() == 0 ? 80 : 0 );
</method>
</view>
<view name="green"
y="canvas.spike1.red.y+canvas.spike1.red.height"
width="200" height="0" bgcolor="green"
options="ignorelayout"/>
<view width="200" height="25" bgcolor="blue" />
</view>
I now take the red view and the green dropdown view and wrap them in a class as I move toward creating a reusable component. Clicking on the red view now inserts the green view in the layout and pushes the blue view down to accommodate it. Not what I was hoping for.
<class name="dropdown">
<view name="red" width="200" height="25"
bgcolor="red" clickable="true">
<method event="onclick">
classroot.green.bringToFront();
classroot.green.setHeight(
classroot.green.getHeight() == 0 ? 80 : 0 );
</method>
</view>
<view name="green"
y="classroot.red.y+classroot.red.height"
width="200" height="0" bgcolor="green"
options="ignorelayout"/>
</class>
<view name="spike2" x="250">
<simplelayout spacing="2"/>
<view width="200" height="25" bgcolor="yellow" />
<dropdown />
<view width="200" height="25" bgcolor="blue" />
</view>
Is there any way to get the class to behave in the same way as the non-class version and still retain the encapsulation required for a component?
Thanks.