-
February 28th, 2018, 02:12 #1
Subwindows and "back referencing" query
I'm trying to call a function from within 2 subwindows all the way back to the top. I'm having trouble finguring it out tho.
The setup is this.
windowclass(readycheck)
-subwindow(main)
--windowclass(ready_check_main)
---subwindow(main_user)
----windowclass(ready_check_entry_user)
From within ready_check_entry_user I want to have a button_checkbox via onValueChanged() refer back to a function in "readycheck".
I'm having trouble figuring out the "path" BACK to readycheck. window.function refers to the script within the windowclass "ready_check_entry_user" so that's not helpful. Been trying to figure out parentcontrol but that doesn't seem to get things back where I need either.
Anyone have some tips on how to reference backwards?---
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.
-
February 28th, 2018, 02:22 #2
Side trip - can you not do this by referencing the DB directly?
-
February 28th, 2018, 02:31 #3---
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.
-
February 28th, 2018, 03:19 #4
You're probably going to have to string parentcontrol and subwindow together: https://www.fantasygrounds.com/refdoc/subwindow.xcp
When I need to work these out I will use lots of Debug.console commands outputting the control name or window instance class name.
So things like: window.getClass() or parentcontrol.getName() and then string them together - window.parentcontrol.getName() etc..
You'll get some nil errors, but it usually helps to go through it a few times to work out the exact hierarchy and how you can string the various API references together.Private 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!
-
February 28th, 2018, 03:28 #5---
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.
-
February 28th, 2018, 03:33 #6Private 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!
-
February 28th, 2018, 04:04 #7
Yup, here is the code I ran from the button and the output I got.
Code:function onButtonPress() local sName = User.getUsername(); window.notifyReadyCheck(sName,1); Debug.console("PC0","window",window); Debug.console("PC1","window.getClass()",window.getClass()); Debug.console("PC2","window.subwindow",window.subwindow); Debug.console("PC3","window.parentcontrol",window.parentcontrol); Debug.console("PC4","window.parentcontrol.getName()",window.parentcontrol.getName()); Debug.console("PC6","window.parentcontrol.subwindow",window.parentcontrol.subwindow); Debug.console("PC7","window.parentcontrol.subwindow.getClass()",window.parentcontrol.subwindow.getClass()); Debug.console("PC8","window.parentcontrol.subwindow.window",window.parentcontrol.subwindow.window); end
Code:Runtime Notice: s'PC0' | s'window' | windowinstance = { class = ready_check_entry_user, node = nil, x,y,w,h = 371,295,246,45 } Runtime Notice: s'PC1' | s'window.getClass()' | s'ready_check_entry_user' Runtime Notice: s'PC2' | s'window.subwindow' | nil Runtime Notice: s'PC3' | s'window.parentcontrol' | subwindow = { x,y,w,h = 0,15,246,45 } Runtime Notice: s'PC4' | s'window.parentcontrol.getName()' | s'main_user' Runtime Notice: s'PC6' | s'window.parentcontrol.subwindow' | windowinstance = { class = ready_check_entry_user, node = nil, x,y,w,h = 371,295,246,45 } Runtime Notice: s'PC7' | s'window.parentcontrol.subwindow.getClass()' | s'ready_check_entry_user' Runtime Notice: s'PC8' | s'window.parentcontrol.subwindow.window' | nil Script Error: [string ""]:1: attempt to index field 'window' (a nil value)
windowclass(readycheck)
-subwindow(main)
--windowclass(ready_check_main)
---subwindow(main_user)<--------------
----windowclass(ready_check_entry_user)---
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.
-
February 28th, 2018, 04:08 #8
OK, so window = ready_check_entry_user and window.parentcontrol.subwindow also = ready_check_entry_user.
So you've gone up then back down with subwindow.
How about window.parentcontrol.window?Last edited by Trenloe; February 28th, 2018 at 04:11.
Private 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!
-
February 28th, 2018, 04:10 #9
The "Scope" section here might also give you some ideas: https://www.fantasygrounds.com/wiki/...pt_Block_Scope
For this you're probably going to need something like: window.parentcontrol.window.parentcontrol.windowLast edited by Trenloe; February 28th, 2018 at 04:12.
Private 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!
-
February 28th, 2018, 04:15 #10
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Celestian, I usually give up and create a temporary node in these cases because I can never walk back up very far. I create the node and then delete it when I'm done. A kluge, but I get brain damage trying to walk up window/subwindow hierarchies like that.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks