Page 1 of 1
Shifting LuaGuiElements
Posted: Fri Feb 01, 2019 1:40 pm
by eduran
I am trying to place multiple UI elements within a flow. A label, textfield, check-box and sprite button. The situation looks like this:

- alignment.JPG (18.89 KiB) Viewed 1202 times
The "refresh" button is supposed to be on the right side. Changing .style.align of the outer flow moves all elements to the right. Since there is no spacing parameter, do I have to add an invisible item between checkbox and button, or is there a better way?
Re: Shifting LuaGuiElements
Posted: Fri Feb 01, 2019 1:44 pm
by Klonan
eduran wrote: Fri Feb 01, 2019 1:40 pm
I am trying to place multiple UI elements within a flow. A label, textfield, check-box and sprite button. The situation looks like this:
alignment.JPG
The "refresh" button is supposed to be on the right side. Changing .style.align of the outer flow moves all elements to the right. Since there is no spacing parameter, do I have to add an invisible item between checkbox and button, or is there a better way?
The way we do it, even internally, is to add a horizontal flow between the widgets and set `flow.style.horizontally_stretchable = true`
Re: Shifting LuaGuiElements
Posted: Fri Feb 01, 2019 2:33 pm
by eduran
Thank you for the quick reply. A follow-up question: Is it possible to place an element next to a frame title, e.g. in the top right corner of the following image:

- frame.JPG (14.71 KiB) Viewed 1194 times
Re: Shifting LuaGuiElements
Posted: Fri Feb 01, 2019 5:45 pm
by Klonan
eduran wrote: Fri Feb 01, 2019 2:33 pm
Thank you for the quick reply. A follow-up question: Is it possible to place an element next to a frame title, e.g. in the top right corner of the following image:
frame.JPG
No, frames are hardcoded in that way...
Re: Shifting LuaGuiElements
Posted: Sun Feb 03, 2019 11:31 am
by Therenas
I assume you want to put an exit-button in the top right corner. Well you can get around the frame issue, by simply not settings a title, and doing it yourself, like this:
Code: Select all
local main_dialog = player.gui.center.add{type="frame", name="main_dialog", direction="vertical"}
local titlebar = main_dialog.add{type="flow", name="flow_titlebar", direction="horizontal"}
titlebar.add{type="label", name="label_titlebar_name", caption="Title"}
titlebar.add{type="flow", name="flow_titlebar_spacing", direction="horizontal"}
titlebar["flow_titlebar_spacing"].style.horizontally_stretchable = true
titlebar.add{type="button", name="button_titlebar_exit", caption="X"}
... adding styling and such, of course.