-
February 24th, 2016, 06:04 #1
- Join Date
- Dec 2015
- Location
- Canada
- Posts
- 207
Problem designing combobox control
Working on a combobox, I've modified the basic comboboxc to be a downward opening combobox, but I'm having a couple issues, with the code below, it seems the width is 0; meanwhile if I give it an explicit anchored "to" tag, then it appears at whatever I set it's width leaf to. I think height is working ok, but I'm unsure. I seem to have to use the relative method of anchoring to ensure that my string_labeled items that sit beside it don't lose their ruler lines, and are in the right places.
When I do use the "to" method, the drop down list seems to only take up a portion of the width of the control, similar to the chat box drop down. Hopefully we can solve some of these issues, must be missing some part of the method.
My combobox control instance:
Code:<comboboxcd name="phenotype"> <anchored> <top parent="detailframe" anchor="top" relation="relative" offset="10" /> <left parent="detailframe" anchor="left" relation="relative" offset="30" /> <width>70</width> <height>15</height> </anchored> <frame> <name>tempmodsmall</name> <offset>25,2,5,4</offset> </frame> <tooltip textres="char_tooltip_phenotype" /> <font>chatfont</font> <listmaxsize>4</listmaxsize> </comboboxcd>
Code:<template name="comboboxc"> <simplestringc> <frame> <name>fieldlight</name> <offset>7,5,7,5</offset> </frame> <readonly /> <listdirection mergerule="replace">up</listdirection> <buttonoffset mergerule="replace">0,1</buttonoffset> <script file="common/scripts/combobox.lua"/> </simplestringc> </template> <template name="comboboxcd"> <simplestringc> <frame> <name>fieldlight</name> <offset>7,5,7,5</offset> </frame> <readonly /> <listdirection mergerule="replace">down</listdirection> <buttonoffset mergerule="replace">0,1</buttonoffset> <script file="common/scripts/combobox.lua"/> </simplestringc> </template>
Ultimate License Holder
-
February 24th, 2016, 06:16 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,559
If you want the comboxc template to have the list items drop down as opposed to up, just add "<listdirection>down</listdirection>" to the control definition where you use comboboxc in your windowclass definition.
Regards,
JPG
-
February 24th, 2016, 06:49 #3
- Join Date
- Dec 2015
- Location
- Canada
- Posts
- 207
I tried that, seems like I may have stuck it in the wrong place, as it didn't work.
But the real issue I'm having, is that when I define it's position with relations it seems to ignore the width parameter. Why is that?Ultimate License Holder
-
February 24th, 2016, 08:28 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,559
It's because the width and height are not defined in the right spot.
From your example above, it should be: (note the size tag under anchored)
Code:<comboboxcd name="phenotype"> <anchored> <top parent="detailframe" anchor="top" relation="relative" offset="10" /> <left parent="detailframe" anchor="left" relation="relative" offset="30" /> <size> <width>70</width> <height>15</height> </size> </anchored> <frame> <name>tempmodsmall</name> <offset>25,2,5,4</offset> </frame> <tooltip textres="char_tooltip_phenotype" /> <font>chatfont</font> <listmaxsize>4</listmaxsize> </comboboxcd>
https://www.fantasygrounds.com/refdoc/windowcontrol.xcp
Regards,
JPG
-
February 24th, 2016, 15:44 #5
- Join Date
- Dec 2015
- Location
- Canada
- Posts
- 207
Heh, thanks, given how many controls I've done manual sizing on so far I shouldn't have made that mistake. Thanks very much.
When I do the drop direction I'd assume it should work if I overload it in the opening line: <comboxc listdirection="down" is that right?Ultimate License Holder
-
February 24th, 2016, 16:53 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,559
Any information that is used by a template must be a child XML tag, since only child tags are accessible by template code, not tag attributes.
Regards,
JPG
-
February 24th, 2016, 18:00 #7
- Join Date
- Dec 2015
- Location
- Canada
- Posts
- 207
Ah, thanks Moon Wizard, that helps.
Now I just have to decode enough of the lua to figure out how they're getting the values into the drop down, and what's assigned to the database for them, and we should be all good!Ultimate License Holder
-
February 24th, 2016, 18:09 #8
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,559
Check out the usage of the control in 3.5E and 5E rulesets to see how they're being used.
Cheers,
JPG
-
February 24th, 2016, 18:27 #9
- Join Date
- Dec 2015
- Location
- Canada
- Posts
- 207
Alright, doing pretty well, but I'm trying to add items to the combobox list, and it doesn't seem to be working, here's the whole set of code, temporary as it is.
Code:<?xml version="1.0" encoding="iso-8859-1"?> <!-- Please see the license.html file included with this distribution for attribution and copyright information. --> <root> <windowclass name="charsheet_notes"> <sheetdata> <frame_char name="detailframe"> <bounds>15,0,-29,80</bounds> </frame_char> <comboboxc name="phenotype"> <anchored> <top parent="detailframe" anchor="top" relation="relative" offset="15" /> <left parent="detailframe" anchor="left" relation="relative" offset="40" /> <size> <width>70</width> <height>15</height> </size> </anchored> <frame> <name>tempmodsmall</name> <offset>25,2,5,4</offset> </frame> <listdirection>down</listdirection> <tooltip textres="char_tooltip_phenotype" /> <font>chatfont</font> <listmaxsize>4</listmaxsize> </comboboxc> <!-- <string_labeled name="phenotype"> <anchored to="detailframe" position="insidetopleft" offset="15,10" width="100" height="20" /> <labelres>char_label_phenotype</labelres> </string_labeled> <right parent="entry" anchor="right" offset="45" /> <bottom parent="entry" anchor="top" relation="relative" offset="-5" /> <left parent="" anchor="center" offset="45" /> --> <string_labeled name="gender"> <anchored to="detailframe" position="insidetopleft" offset="125,10" width="70" height="20" /> <labelres>char_label_gender</labelres> </string_labeled> <string_labeled name="age"> <anchored to="gender" position="right" offset="5,0" width="35" /> <labelres>char_label_age</labelres> </string_labeled> <string_labeled name="height"> <anchored to="age" position="right" offset="5,0" width="40" /> <labelres>char_label_height</labelres> </string_labeled> <stringcontrol name="height_label"> <anchored to="height" position="right" offset="2,0" /> <font>sheettext</font> <static>cm</static> </stringcontrol> <string_labeled name="weight"> <anchored to="height_label" position="right" offset="5,0" width="40" /> <labelres>char_label_weight</labelres> </string_labeled> <stringcontrol name="weight_label"> <anchored to="weight" position="right" offset="2,0" /> <font>sheettext</font> <static>kg</static> </stringcontrol> <string_labeled name="hair"> <anchored> <top parent="phenotype" anchor="bottom" relation="relative" offset="10" /> <left parent="detailframe" anchor="left" relation="relative" offset="20" /> <size> <width>60</width> <height>20</height> </size> </anchored> <labelres>char_label_hair</labelres> </string_labeled> <string_labeled name="eyes"> <anchored to="hair" position="right" offset="5,0" width="40" /> <labelres>char_label_eyes</labelres> </string_labeled> <string_labeled name="affiliation"> <anchored to="eyes" position="right" offset="5,0" width="70" /> <labelres>char_label_affiliation</labelres> </string_labeled> <string_labeled name="extra"> <anchored to="affiliation" position="right" offset="5,0" width="70" /> <labelres>char_label_extra</labelres> </string_labeled> <script> function onInit() local w = Interface.findWindow("charsheet_notes", ""); w.phenotype.clear(); w.phenotype.add("Test","Test"); end </script> </sheetdata> </windowclass> </root>
What am I missing? There are no errors in console at any point, on load, change, etc.Last edited by GrimmSpector; February 24th, 2016 at 19:57.
Ultimate License Holder
-
February 24th, 2016, 21:01 #10
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,559
Your script is using findWindow to find a window with a class of "charsheet_notes" and no database connection. It seems like you should be getting an error on the second line, since no window like this should exist. Since I'm assuming this is a PC sheet, it should be tied to a database node. Also, the findWindow function only returns top-level windows, such as the entire character sheet.
In some ways, the above information is irrelevant, since the findWindow is not required. You are already running the script within a windowinstance, so the named controls are directly accessible.
Code:<script> function onInit() phenotype.clear(); phenotype.add("Test"); end </script>
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks