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
Dynamic Combobox and Choice data
Dynamic Combobox and Choice data
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Dynamic Combobox and Choice data
Unfortunately, this is currently unsupported but it's planned for the future...
Re: Dynamic Combobox and Choice data
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$)
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$)
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Dynamic Combobox and Choice data
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.
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Dynamic Combobox and Choice data
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
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Dynamic Combobox and Choice data
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
Excellent...awaiting for next release