Page 1 of 1
[0.18.27] Close buttons in window headers
Posted: Sun May 31, 2020 6:28 pm
by bobingabout
The post about
0.18.27 change to GUI stuff mentions creating a window with style standalone_inner_frame_in_outer_frame then adding buttons in the header, such as the close button, with the style frame_action_button.
Maybe I'm missing something here, but how exactly are we supposed to add the buttons to a window's header?
Re: [0.18.27] Close buttons in window headers
Posted: Mon Jun 01, 2020 12:16 am
by bobingabout
I've managed to "fake it", which works on windows that don't move.
The fake version has no window caption, so no automatic title bar, so I add one afterwards and just put the X button right of the title, with a stretchable filler between
https://www.dropbox.com/s/093t1xkaypvgo ... 5.png?dl=0
https://www.dropbox.com/s/9zuacexyhfodk ... 8.png?dl=0
But, I can't really do that when the window is movable in the screen layer... the closest I've managed to get is this:
https://www.dropbox.com/s/weggq47h8d5ev ... 3.png?dl=0
If there is no official way to do it, I can share my bodge code if people want to see it.
Re: [0.18.27] Close buttons in window headers
Posted: Mon Jun 01, 2020 7:47 am
by Klonan
You just add the title and the pusher and button yourself:
This
Code: Select all
local title_flow = frame.add{type = "flow", name = "title_flow"}
local title = title_flow.add{type = "label", caption = title_caption, style = "frame_title"}
title.drag_target = frame
local pusher = title_flow.add{type = "empty-widget", style = "draggable_space_header"}
pusher.style.vertically_stretchable = true
pusher.style.horizontally_stretchable = true
pusher.drag_target = frame
title_flow.add{type = "sprite-button", style = "frame_action_button", sprite = "utility/close_white", name = "close_road_network_gui"}
Looks like this:

Re: [0.18.27] Close buttons in window headers
Posted: Mon Jun 01, 2020 11:35 am
by bobingabout
Klonan wrote: Mon Jun 01, 2020 7:47 am
You just add the title and the pusher and button yourself:
This
Code: Select all
local title_flow = frame.add{type = "flow", name = "title_flow"}
local title = title_flow.add{type = "label", caption = title_caption, style = "frame_title"}
title.drag_target = frame
local pusher = title_flow.add{type = "empty-widget", style = "draggable_space_header"}
pusher.style.vertically_stretchable = true
pusher.style.horizontally_stretchable = true
pusher.drag_target = frame
title_flow.add{type = "sprite-button", style = "frame_action_button", sprite = "utility/close_white", name = "close_road_network_gui"}
Looks like this:
Pretty much what I was doing except for the drag_target part.
Thanks for the help.