Allow enter-key for confirming dialogs

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 250
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Allow enter-key for confirming dialogs

Post by Therenas »

I would love it if I could confirm a dialog with ENTER. As it currently works, you can detect keyboard shortcuts only when no textfield is selected/in focus, so pressing ENTER directly after typing can't be detected by mods. Now I see how custom shortcuts won't work in a textfield, as for example CTRL+A selects all text, etc. But one set key (ENTER seems suitable) that, when pressed when a textfield is in focus, fires an 'submit-event' to be caught by mods, would really make for a nicer UI experience. As a user, a form that doesn't submit with ENTER really seems broken.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14363
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Allow enter-key for confirming dialogs

Post by Rseding91 »

I can implement this for single-line text boxes but it's not going to work for multi-line ones since enter is "add new line" and not "submit".
If you want to get ahold of me I'm almost always on Discord.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Allow enter-key for confirming dialogs

Post by Nexela »

Most programs with multi line text boxes use CTRL+ENTER to send it, would it be viable to add this combination to multiline boxes?
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Allow enter-key for confirming dialogs

Post by bobingabout »

Nexela wrote: Thu Jan 10, 2019 12:13 am Most programs with multi line text boxes use CTRL+ENTER to send it, would it be viable to add this combination to multiline boxes?
I thought it was Shift + Enter.

Still, I'd probably agree with Rseding, I'd want the default behaviour of a multi-line text box to be new line, not send, where message boxes (like the console) should be (and the console actually is) enter to submit.

that yellow box that appears at the start of a new game that says "Press tab to close", I must admit, I've tried pressing Escape and Enter to close it.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
zysnarch
Burner Inserter
Burner Inserter
Posts: 10
Joined: Thu Jan 10, 2019 4:26 am
Contact:

Re: Allow enter-key for confirming dialogs

Post by zysnarch »

Just chiming in to support this idea - I was about to ask the same thing.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 250
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Allow enter-key for confirming dialogs

Post by Therenas »

Yeah I totally agree that in multi-line ones, enter should go to the next line. Implementing a shift-enter or ctrl-enter would be nice, but not as important, as those multi-line boxes aren't used for some quick input typically, thus aren't used as frequently, which makes enter not working less annoying.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 250
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Allow enter-key for confirming dialogs

Post by Therenas »

Boodals and I just talked a bit about this on discord, and a different way to implement this came to mind: You could have a field on the textfield/box that you set. You give it a reference to a button object, and when the user hits enter on it, that button gets programmatically pressed. This way, it would not require a new event, which I‘m told is kinda annoying to implement. It might not be the 100% clean way to do it, but it‘ll work.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Allow enter-key for confirming dialogs

Post by eradicator »

Therenas wrote: Fri May 31, 2019 6:15 pm Boodals and I just talked a bit about this on discord, and a different way to implement this came to mind: You could have a field on the textfield/box that you set. You give it a reference to a button object, and when the user hits enter on it, that button gets programmatically pressed. This way, it would not require a new event, which I‘m told is kinda annoying to implement. It might not be the 100% clean way to do it, but it‘ll work.
How about adding "button" to the on_gui_text_changed event (same as on_gui_click)? That also makes it easy to add ctrl/shift modifiers. Doesn't invent new api concepts like "event for a different element", and keeps the events seperated for different element types.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 580
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Allow enter-key for confirming dialogs

Post by raiguard »

+1 from me! I would like users of my mod to be able to press enter to dismiss this textfield:

Image
Don't forget, you're here forever.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 580
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Allow enter-key for confirming dialogs

Post by raiguard »

I am going to add a few more things to this request, all in the effort to mimic how textfields work in the vanilla settings GUI. Along with enter-to-confirm, I would like to have a way to detect the focused state of a textfield (or maybe just any GUI element). Something like element.get_focused_state(), or an event that fires when something is focused / unfocused, such as on_gui_element_focused and on_gui_element_unfocused.

Either one of these, combined with the ability to press enter to confirm, would allow me to make my settings GUI behave consistent with the vanilla settings GUI.

Thanks for your time!
Don't forget, you're here forever.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 250
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Allow enter-key for confirming dialogs

Post by Therenas »

You can detect an element being focused by listening to https://lua-api.factorio.com/latest/eve ... _gui_click, it works for textfields too.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 250
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Allow enter-key for confirming dialogs

Post by Therenas »

This just got added for 0.17.57, thanks guys! (Can be moved)
Post Reply

Return to “Implemented mod requests”