[0.16.x] Setting LuaControl::opened with LuaGuiElement
Posted: Sun Dec 31, 2017 4:20 pm
From the 0.16.0 changelog:
AFAICT the only way to get a new LuaGuiElement is to add it to an existing root container in a LuaGui. Setting opened to this LuaGuiElement works, but when pressing E or Esc to close the GUI, opened is reset to nil, but the LuaGuiElement is still displayed onscreen because it's still part of the LuaGui's root container. I haven't found a way to detach it from a LuaGui, since children is read-only and clear() and destroy() remove the LuaGuiElement even if it's the current target of opened.
My test code:
How exactly is this intended to work?Added support for setting a LuaGuiElement as the opened GUI for a player causing it to close with the normal close-GUI methods.
AFAICT the only way to get a new LuaGuiElement is to add it to an existing root container in a LuaGui. Setting opened to this LuaGuiElement works, but when pressing E or Esc to close the GUI, opened is reset to nil, but the LuaGuiElement is still displayed onscreen because it's still part of the LuaGui's root container. I haven't found a way to detach it from a LuaGui, since children is read-only and clear() and destroy() remove the LuaGuiElement even if it's the current target of opened.
My test code:
Code: Select all
local function show_gui(player)
local frame = player.gui.center.add{
type = "frame",
name = "my-config",
direction = "vertical",
}
frame.add{
type = "label",
name = "title",
caption = "My Config",
}
player.opened = frame
end