Page 1 of 1

Dynamic Combobox and Choice data

Posted: Fri Jul 08, 2016 1:05 pm
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

Re: Dynamic Combobox and Choice data

Posted: Fri Jul 08, 2016 10:28 pm
by airsoftsoftwair
Unfortunately, this is currently unsupported but it's planned for the future...

Re: Dynamic Combobox and Choice data

Posted: Thu Oct 13, 2016 9:08 am
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$)

Re: Dynamic Combobox and Choice data

Posted: Thu Oct 13, 2016 5:24 pm
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.

Re: Dynamic Combobox and Choice data

Posted: Sun Nov 13, 2016 12:58 pm
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

Re: Dynamic Combobox and Choice data

Posted: Thu Nov 17, 2016 4:43 pm
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

Re: Dynamic Combobox and Choice data

Posted: Fri Nov 18, 2016 5:08 pm
by ilbarbax
Excellent...awaiting for next release