PDA

View Full Version : Subwindow to Subwindow



Xarxus
November 11th, 2023, 10:48
Starting from a subwindow, I need to get access to a control in another subwindow.
If I'm not wrong, there was an utility function already prepared to do this job, but I can't find it.
Who can help me?

Trenloe
November 11th, 2023, 11:11
According to the developer guide for the subwindow control, "a reference to the parent subwindow control is available from the contained windowinstance object through the parentcontrol variable." https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996645196/subwindow

Not knowing your exact GUI control hierarchy, you could try something like parentcontrol.window.{name of other subwindow}.subwindow to access another subwindow from within a different subwindow. If this doesn't work, you can usually work out the path needed by use of Debug statements for parentcontrol.window and other variations on that GUI path.

Trenloe
November 11th, 2023, 11:13
If I'm not wrong, there was an utility function already prepared to do this job, but I can't find it.
Search for parentcontrol in the CoreRPG manager_utility.lua file for some functions related to this. getTopWindow(w) returns the top window, if w is a subwindow then it just uses parentcontrol.window to get to the top level window.

Xarxus
November 12th, 2023, 09:41
Yep, I was using this --> parentcontrol.window.{name of other subwindow}.subwindow, but when I try to reach a control inside it seems to not work.
I think I should get to the windowinstance first, is that right?

getTopWindow(w) is the same, it gives the subwindow.

I tried this



_wMyWindow = parentcontrol.window["myWindow"].subwindow;

Debug.console(_wMyWindow); -- The output is --> subwindow = { name = "myWindow", x,y,w,h = 30,45,600,635 }

_wMyWindow["myControlName"].getValue(); -- It doesn't work
_wMyWindow.myControlName.getValue(); -- It doesn't work


What I'm doing wrong?

Trenloe
November 12th, 2023, 10:30
Write debug for the controls you're trying to access. Output _wMyWindow.myControlName to debug, for example.

Also, ensure that the subwindow and its contents has been fully created when you're trying to access it via code. You may need to specify <activate /> in the subwindow definition: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996645196/subwindow

Xarxus
November 16th, 2023, 19:11
Gotcha! Solved --> fastinit is the way

Ty Trenloe