-
June 24th, 2019, 06:39 #1
createControl() with windowreferencecontrol
I am attempting to use createControl to create a link button that will open a class/record I setValue() on the control.
Here is the template I use.
Code:<template name="link_inventory_item_ct"> <linkcontrol> <script> function onDragStart(button, x, y, draginfo) local sClass, sRecord = getValue(); local node = DB.findNode(sRecord); if node then local sName = DB.getValue(node,"name",""); local sPathToItem = node.getPath(); draginfo.setType("shortcut"); draginfo.setShortcutData( sClass, sRecord ); draginfo.setDescription(sName); draginfo.setIcon("button_link_down"); return true; end end function onButtonPress() local sClass, sRecord = getValue(); if sClass and sRecord then local sPathToItem = node.getPath(); Interface.openWindow(sClass, sRecord); return true; end end </script> <anchored > <top /> <left /> </anchored> <icon normal="button_link" pressed="button_link_down" empty="button_link_empty" /> </linkcontrol> </template>
Code:local controlItemLink = createControl("link_inventory_item_ct", sControlItemLink); controlItemLink.setAnchor("top", sControlItemName,"top","absolute",10); controlItemLink.setAnchor("left", sControlItemName,"right","absolute",0); controlItemLink.setAnchor("right", sControlItemName,"right","absolute",-20); controlItemLink.setValue('item',nodeItem.getPath());
The result of my code is something like this. (I also createControl for the count and name of the items)
This item list is generated from a single string, not a list of nodes. My use case is to eliminate the inventorylist objects on npcs while in the CT but also be able to "see" the items and link back to the source NPC record that it came from. So far all this works it's just I can't seem to get the link buttons to interact.---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
June 24th, 2019, 13:39 #2
I'm guessing it's a problem with the positioning/anchoring. It looks like your setting the right side of your control to be further to the left than the left side.
If your control template has a width, then there's no need to set the right anchor - as you've set the left anchor to the same control. If your template doesn't have a width, try setting the control width using setAnchoredWidth - https://www.fantasygrounds.com/refdo...tAnchoredWidthPrivate Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
June 24th, 2019, 16:06 #3
That was it, more or less, I was placing the "buttons" underneath the label so clicks went to label, not the "button" that was under. I assumed that since it was AFTER the label it would be on top. Got it functional now, thanks for the tip
What I had to do was "achor" my "left" side of the button to the right side of the "contentanchor" and not the label. Once I did that I was able to use a offset so the button was on the "frame" (shaded/non-shaded variants) and/or on top and the button works.Last edited by celestian; June 24th, 2019 at 16:25.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
June 24th, 2019, 18:05 #4
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Thanks for the explanation, Celestian
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks