[0.18.27] Close buttons in window headers

Place to get help with not working mods / modding interface.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

[0.18.27] Close buttons in window headers

Post 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?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.18.27] Close buttons in window headers

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5411
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.18.27] Close buttons in window headers

Post 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:
Image
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.18.27] Close buttons in window headers

Post 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:
Image
Pretty much what I was doing except for the drag_target part.
Thanks for the help.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”