Having the ability to close mod windows with escape

Things that already exist in the current mod API
Post Reply
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Having the ability to close mod windows with escape

Post by Therenas »

Similar to an older request of mine (link), there are some common interactions a user expects to work. One which is currently missing for modders is the ability to close a window with escape. Pretty much all stock windows can be closed with escape, so it would really improve the consistency of the user experience if mod windows could be too.

With the current keyboard shortcut functionality, it is not really possible due to how those events work. You can either catch the escape key all the time, making it not work for non-mod windows, or you can let it through, triggering the pause menu for example even when you only wanted to close your mod window. (although FNEI seems to have found a way to do it, I haven't worked out how yet, and it is probably kinda hacky)

So it would be awesome if we could have our mod windows close with escape. It might be able to work by the modder setting a flag on a frame element indicating it should be closeable with escape. When the user then presses escape with that window being the focus, it raises an event in which the modder can handle the closing/hiding of the window. Just as an idea, I don't know how all this works behind the scenes of course.

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Having the ability to close mod windows with escape

Post by Bilka »

Already exists, set LuaPlayer::opened to your GUI when it is opened and then close your GUI in defines.events.on_gui_closed.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Already exists”