LavishUI ComboBox problem

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
Xeon
Non-Subscriber
Posts: 10
Joined: Mon Jan 22, 2007 2:30 am

LavishUI ComboBox problem

Post by Xeon » Mon Apr 23, 2007 1:56 pm

I'm using a LavishUI ComboBox and filling it from a LavishScript:

I load a Skin.xml file first, then the ui.xml file. Here is the code:

Code: Select all

<ComboBox Name="RecipeSelectCombo" Template="VG.ComboBox">
	<X>20</X>
	<Y>40</Y>
	<Width>80%</Width>
	<Height>20</Height>
	<OnSelect>
Script[VGCraftBot].VariableScope.recipeName&#58;Set[$&#123;This.SelectedItem.Text&#125;]
	</OnSelect>
</ComboBox>
And the fill code:

Code: Select all

while &#40; $&#123;rCount&#58;Inc&#125; <= $&#123;Refining.RecipeCount&#125; &#41;
&#123;
UIElement[RecipeSelectCombo@Recipe@CraftMain@CraftBot]&#58;AddItem[$&#123;Refining.Recipe[$&#123;rCount&#125;].Name&#125;]
&#125;
The first time I run my script, the text in the ComboBox is small white and I can not select any of the items correctly.

The 2nd time I run my script everything works just fine.

Any ideas?

Zeek
GamingTools Subscriber
Posts: 1
Joined: Tue Jun 21, 2005 12:30 am

Post by Zeek » Mon Apr 23, 2007 2:11 pm

I am also seeing the same issue but with a more simple pulldown. Also using the sort value seems to constantly change the order based off of the current selection.

Code: Select all

						<ComboBox name="MeleeCombo" template="VG.ComboBox">
							<X>110</X>
							<Y>98</Y>
							<Width>50%</Width>
							<Height>20</Height>
							<Items>
								<Item value='1'>No Melee</Item>
								<Item value='2' default='1'>Melee dont Move</Item>
								<Item value='3'>Melee and Move</Item>
							</Items>
							<Sort>None</Sort>
						</ComboBox>
Zeek

Unchayned
GamingTools Subscriber
Posts: 51
Joined: Sat Oct 09, 2004 9:22 am

Post by Unchayned » Mon Apr 23, 2007 7:24 pm

Come to think of it, I've also noticed combobox being a little wonky, but I usually only have like 2-3 items populated and never gave it much thought.

Looking at the wiki, it seems that they're built on top of listboxes. I'd try creating the listbox manually rather than pulling it from a template and see how manipulating the listbox directly rather than/along with the combobox works. It could be a problem with templating, or the sort method not getting passed from the combo to the list or somesuch.

I've got no idea what could be causing the thing with it screwing up the first time you run it, Xeon...are you absolutely sure that your skin's getting loaded on the first run and there's no problems there? (BTW, assuming everything's named correctly you can load with "ui -skin VG" and let the default templating take over if you want to drop all of those template= statements from your XMLs, providing your skin's set up to mirror the default templates)

Unchayned
GamingTools Subscriber
Posts: 51
Joined: Sat Oct 09, 2004 9:22 am

Post by Unchayned » Mon Apr 23, 2007 7:29 pm

One other tip, if you poll the value of the box directly, you can save yourself that OnSelect section. One less variable to declare, and your UI will be more portable to other scripts since you've dropped the dependency on passing an argument to Script[] to access the variablescope.

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Tue Apr 24, 2007 10:06 am

Hate to tell you this but whenever I test something when you say it's a problem with comboboxes, i'm going to rip the Template out of it. I'm loading this as per Zeek's post

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<ISUI>
                  <ComboBox name="MeleeCombo">
                     <X>110</X>
                     <Y>98</Y>
                     <Width>50%</Width>
                     <Height>20</Height>
                     <Items>
                        <Item value='1'>No Melee</Item>
                        <Item value='2' default='1'>Melee dont Move</Item>
                        <Item value='3'>Melee and Move</Item>
                     </Items>
                     <Sort>None</Sort>
                  </ComboBox> 
</ISUI>
... and it looks and operates just fine. I'm not sure what you mean by
Also using the sort value seems to constantly change the order based off of the current selection.
You'll have to provide a code sample or something, because I don't know what you are saying is happening

Then, Xeon, if I do UIElement[MeleeCombo]:AddItem[anything here] ... it adds it to the bottom of the list.

I don't see anything particularly interesting or wrong with what you've given me. If you want to show me what may be a bug, you will have to provide a simple test script

Xeon
Non-Subscriber
Posts: 10
Joined: Mon Jan 22, 2007 2:30 am

Post by Xeon » Tue Apr 24, 2007 12:43 pm

Lax wrote:Hate to tell you this but whenever I test something when you say it's a problem with comboboxes, i'm going to rip the Template out of it.
Yep, that was it! Thanks Lax and sorry for the erroneous bug report

Turns out that the VG.ComboBox template used this template

Code: Select all

<!-- ListBox -->
	<Template Name="VG.ListBox.Texture" Filename=".\Textures\VgrdBackground.bmp">
		<Left>1</Left>
		<Right>500</Right>
		<Top>1</Top>
		<Bottom>500</Bottom>
		<Border>1</Border>
	</Template>
When I changed the filename from a .bmp file to a .tga file like the rest of the templates are using, it worked as designed.

Xeon
Non-Subscriber
Posts: 10
Joined: Mon Jan 22, 2007 2:30 am

Post by Xeon » Tue Apr 24, 2007 12:59 pm

Ignore that last post, I was fooled by the reload issue, which pointed me to the actual problem.

The real problem was that the VG.ComboBox was using VG.ListBox templates that were defined AFTER the VG.ComboBox definition.

Once I moved the ListBox templates to before the ComboBox templates it loads and works as expected.

Post Reply