Dynamic Combobox and Choice data

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
Redlion
Posts: 94
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Dynamic Combobox and Choice data

Post by Redlion »

Hi all,

I was trying to load data into a combobox and a choice gadget from a file.

I have tried moai.set("combo", -1, Data$ ), I can not seem to find the right syntax?

Has anyone been able to do this.

Is it possible to do?

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Dynamic Combobox and Choice data

Post by airsoftsoftwair »

Unfortunately, this is currently unsupported but it's planned for the future...
ilbarbax
Posts: 112
Joined: Thu Apr 01, 2010 6:41 pm

Re: Dynamic Combobox and Choice data

Post by ilbarbax »

I did in this way. At least it works the first time you open the xml file to populate the choice box from a file.

I created a text file with my entries like this one
Abarth
Acura
Alfa Romeo
AM General
American Motors
Aston Martin


then I modified the xml file in such way

...
<label>Maker:</label>
<choice>
##MAKERS##
</choice>


then i id did that it the hws code:

aa$=""
For s$ In FileLines("Makers.txt") Do aa$=aa$.."<item>"..s$.."</item>"..Chr(10)

f$=FileToString("my_car.xml")
f$=ReplaceStr(f$,"##MAKERS##",aa$)

moai.CreateApp(f$)
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Dynamic Combobox and Choice data

Post by airsoftsoftwair »

Of course, you could always use moai.CreateObject() to create a a combobox dynamically and then add it using Group.Insert(), Group.Append() or Group.Prepend(). This allows you to work around the limitation that you currently cannot modify the contents of a choice widget.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Dynamic Combobox and Choice data

Post by airsoftsoftwair »

Code: Select all

- New: Added new methods and attributes for Combobox class which make it much more
  flexible; the following new methods are now supported: Combobox.Clear(), Combobox.GetEntry(),
  Combobox.Insert(), Combobox.Remove(), and Combobox.Rename(); additionally, a
  Combobox.Count [G] attribute has been added to allow you to query the number of
  items in a combobox
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Dynamic Combobox and Choice data

Post by airsoftsoftwair »

Code: Select all

- New: Added new methods and attributes for Choice class which make it much more
  flexible; the following new methods are now supported: Choice.Clear(), Choice.GetEntry(),
  Choice.Insert(), Choice.Remove(), and Choice.Rename(); additionally, a Choice.Count [G]
  attribute has been added to allow you to query the number of items in the widget; 
  finally, it is now possible to declare empty choice widgets in XML, i.e. you needn't
  add items in XML any longer but you can simply do this later at runtime using the
  new methods; also note that only Choice.GetEntry() and Choice.Count [G] are compatible
  with MUI 3.8; all other methods need MUI 4 or better
ilbarbax
Posts: 112
Joined: Thu Apr 01, 2010 6:41 pm

Re: Dynamic Combobox and Choice data

Post by ilbarbax »

Excellent...awaiting for next release
Post Reply