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?
[0.18.27] Close buttons in window headers
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.18.27] Close buttons in window headers
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.
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
You just add the title and the pusher and button yourself:
This
Looks like this:

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:

- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [0.18.27] Close buttons in window headers
Pretty much what I was doing except for the drag_target part.Klonan wrote: Mon Jun 01, 2020 7:47 am You just add the title and the pusher and button yourself:
ThisCode: 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:
![]()
Thanks for the help.