-
May 28th, 2018, 05:23 #1
Window/Parentcontrol/Subwindow navigation (up/down)
So, I'm trying to navigate from down in a subwindow, up then back down into another to get a value set for a "edit" button.
Code:Runtime Notice: s'list_abilitynotes' | s'window' | windowinstance = { class = combat_mini_section, node = combattracker.list.id-00002, x,y,w,h = 640,254,389,140 } Runtime Notice: s'list_abilitynotes' | s'window.parentcontrol.getName' | s'mini_combat_window' Runtime Notice: s'list_abilitynotes' | s'window.parentcontrol.window' | windowinstance = { class = charsheet_combat, node = combattracker.list.id-00002, x,y,w,h = 610,199,469,515 } Runtime Notice: s'list_abilitynotes' | s'window.parentcontrol.window.weapons' | subwindow = { x,y,w,h = 15,197,442,308 } Runtime Notice: s'list_abilitynotes' | s'window.parentcontrol.window.weapons.subwindow' | nil Runtime Notice: s'list_abilitynotes' | s'window.parentcontrol.window.weapons.actions_iedit' | nil Runtime Notice: s'list_abilitynotes' | s'window.parentcontrol.window.subwindow' | nil Runtime Notice: s'list_abilitynotes' | s'window.parentcontrol.window.abilitynotes_iadd' | buttoncontrol = { x,y,w,h = 414,35,0,0 }
charsheet_combat contains the subwindow "weapons" which you can see returns "subwindow" in the debug output... so I expect window.parentcontrol.window.weapons.subwindow to work... but it doesn't as you can see from the "nil" result.
I need to get the value from *.weapons.subwindow.actions_iedit.getValue().
I did a test to see if I could access another variable within charsheet_combat (abilitynotes_iadd) and I could access that item (last thing listed in debug) so it's within the same scope but I'm stumped why *.weapons.subwindow doesn't work as I'd expect it.
Here is the charsheet_combat clipped section.
Code:<windowclass name="charsheet_combat"> <sheetdata> <anchor_title_charsheet name="contentanchor" /> <!-- mini combat window --> <label_charframetop name="minicombattitle"> <anchored height="20"> <top offset="35" /> <left offset="30" /> <right offset="-50" /> </anchored> <icons>char_abilities</icons> <static textres="char_label_combat" /> </label_charframetop> <button_iadd_abilitynotes name="abilitynotes_iadd"> <anchored to="minicombattitle" position="insidetopright" offset="5,0" /> <target>abilitynotes</target> </button_iadd_abilitynotes> <subwindow name="mini_combat_window"> <anchored to="minicombattitle"> <top anchor="bottom" /> <left /> <right /> </anchored> <class>combat_mini_section</class> <activate /> <fastinit /> </subwindow> <!-- END mini combat window --> <sub_sheet_actions name="weapons"> <anchored to="contentanchor"> <top parent="mini_combat_window" anchor="bottom" offset="2" /> <left /> <right parent="" offset="-12,0" /> <bottom parent="" offset="-10" /> </anchored> <class>charsheet_actions_weapons</class> </sub_sheet_actions>
Code:<windowclass name="charsheet_actions_weapons"> <margins control="0,0,15,7" /> <script> function onDrop(x, y, draginfo) if contents.subwindow.weapons.onDrop(x, y, draginfo) then return true; end return false; end </script> <sheetdata> <button_iedit name="actions_iedit"> <anchored position="insidebottomright" offset="10,10" /> <tooltip textres="char_tooltip_actionedit" /> <script> function onValueChanged() local bEditMode = (getValue() == 1); window.weapons_iadd.setVisible(bEditMode); window.parentcontrol.window.abilitynotes_iadd.setVisible(bEditMode); if bEditMode then DB.setValue(window.getDatabaseNode(), "powermode", "string", "standard"); DB.setValue(window.getDatabaseNode(), "powerdisplaymode", "string", ""); end window.contents.subwindow.weapons.update(); window.parentcontrol.window.mini_combat_window.subwindow.abilitynotes.update(bEditMode) end </script> </button_iedit>
What I am trying to do is get the "value" of the button to determine if the button is indeed in edit mode is a rather roundabout way but right now that's only I can for now.
I'm going to keep poking at this but I've exhausted my theories on how to get down to the value.---
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.
-
May 28th, 2018, 05:28 #2
Okay, so ignore me.... it works. Apparently at the point my code was running it didn't exist yet.. /slap.
I ran the button edit toggle and sure enough *.weapons.subwindow.actions_iedit exited.
Sometimes you got to ignore your gut feeling and start all over from scratch.
edit, if anyone cares here is the hoops I did to get to the right values.
Code:function update(bEdit) if bEdit == nil then if (window.parentcontrol.window.weapons.subwindow and window.parentcontrol.window.weapons.subwindow.actions_iedit) then bEdit = (window.parentcontrol.window.weapons.subwindow.actions_iedit.getValue() == 1); elseif (window.parentcontrol.window.parentcontrol.window.actions_iedit) then bEdit = (window.parentcontrol.window.parentcontrol.window.actions_iedit.getValue() == 1); end end for _,w in ipairs(getWindows()) do w.idelete.setVisibility(bEdit); end end
Last edited by celestian; May 28th, 2018 at 05:44.
---
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.
-
May 28th, 2018, 05:51 #3
There's the <fastinit/> I think for subwindows. Worth a look at.
-
May 28th, 2018, 07:18 #4---
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.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks