5E Product Walkthrough Playlist
Page 1 of 2 12 Last
  1. #1

    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>
    And the original, followed by my slightly adjusted template:

    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

  2. #2
    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

  3. #3
    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

  4. #4
    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>
    More detail of the XML format can be found here:
    https://www.fantasygrounds.com/refdoc/windowcontrol.xcp

    Regards,
    JPG

  5. #5
    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

  6. #6
    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

  7. #7
    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

  8. #8
    Check out the usage of the control in 3.5E and 5E rulesets to see how they're being used.

    Cheers,
    JPG

  9. #9
    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>
    After looking at the "add" function from the combobox.lua, seems that it should be working fine, with a nil value being passed to the database as the value for the setting, and the text string being "String", but it doesn't seem to be getting setup.

    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

  10. #10
    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>
    Regards,
    JPG

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in