PDA

View Full Version : combobox bug?


joemcglynn
01-27-2004, 03:26 PM
I have another post asking about how to set the initial value for a combo box. The error I'm getting appears to indicate a bug in baselist.lzx. I stripped out the extra code, the following static example demonstrates the behavior I'm seeing.

If I run this with the debugger on I get the following errors (and no initial value is set for the combo box):
base/baselist.lzx:254: reference to undefined property 'subviews'
base/baselist.lzx:254: undefined object does not have a property 'length'
base/baselist.lzx:254: reference to undefined property 'length'

If I press the button it sets the initial value just fine. Am I missing something or is this a bug? Is there a work-around?

-------code----------
<dataset name="items">
<item value="item1" >item one</item>
<item value="item2" >item two</item>
<item value="item3" >item three</item>
<item value="item4" >item four</item>
</dataset>

<view x="30" y="30">

<simplelayout axis="y"/>

<combobox name="cbox1"
width="130"
defaulttext="choose one...">
<textlistitem datapath="items:/item/" text="$path{'text()'}"
value="$path{'@value'}"/>

<method event="oninit">
selectItem( "item1" );
</method>

</combobox>

<button>Select item with value of "item1"
<method event="onclick">
parent.cbox1.selectItem( "item1" );
</method>
</button>

</view>

</canvas>

antun
02-04-2004, 10:02 AM
The problem is that the <textlistitem>s that you're seeing are not inited at the time when combobox inits. I think it's because they are replicated. Normally a view sends its oninit event after its children have inited.

Instead, you can do something like:


<canvas debug="true">
<dataset name="items">
<item value="item1" >item one</item>
<item value="item2" >item two</item>
<item value="item3" >item three</item>
<item value="item4" >item four</item>
</dataset>

<view x="30" y="30">

<simplelayout axis="y"/>

<combobox name="cbox1"
width="130"
defaulttext="choose one...">
<textlistitem text="$path{'text()'}"
value="$path{'@value'}"
oninit="Debug.write( 'oninit in textlistitem' )"
datapath="items:/item/" />

<method event="oninit" reference="this.cblist">
this.selectItem( "item2" );
</method>
</combobox>

<button>Select item with value of "item1"
<method event="onclick">
parent.cbox1.selectItem( "item1" );
</method>
</button>

</view>

</canvas>


-Antun

tspratt
02-27-2004, 11:53 AM
Specifically, what is "cblist"?

antun
02-27-2004, 12:13 PM
Ah, my bad! I meant to name the <textlistitem> in the code I posted "cblist":


<textlistitem text="$path{'text()'}"
value="$path{'@value'}"
oninit="Debug.write( 'oninit in textlistitem' )"
datapath="items:/item/"
name="cblist" />


-Antun