Window access children||doc136848

September 20, 2022

Window objects can be passed directly The name of the child accesses the child instance object. For example, if you want to access the window instance named "icon" of the child, you can use Access.

image.png

local testWindow = UI:CreateGUIWindow("APITest", "windowInstanceName")
testWindow.Parent = UI.Root
print(UI.Root.windowInstanceName.ID, testWindow.ID)

By comparing the printed window instance ID and the ID referenced by the saved window instance, it can be found that they are the same window instance. Note that the name here is the instance name, that is, the second parameter in the ui:createguiwindow function, not the name of the layout.

Window instances cannot have duplicate names.

image.png

When the name of the child window instance has the same name as the parent property Will access the child window.

image.png

local testWindow = UI:CreateGUIWindow("APITest", "windowInstanceName")
print(testWindow.Name)

You can see from printing that when the child name has the same name as the attribute Access child instances first.