Allow enter-key for confirming dialogs
Allow enter-key for confirming dialogs
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.
Re: Allow enter-key for confirming dialogs
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.
Re: Allow enter-key for confirming dialogs
Most programs with multi line text boxes use CTRL+ENTER to send it, would it be viable to add this combination to multiline boxes?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Allow enter-key for confirming dialogs
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.
Re: Allow enter-key for confirming dialogs
Just chiming in to support this idea - I was about to ask the same thing.
Re: Allow enter-key for confirming dialogs
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.
Re: Allow enter-key for confirming dialogs
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.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Allow enter-key for confirming dialogs
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.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.
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Allow enter-key for confirming dialogs
+1 from me! I would like users of my mod to be able to press enter to dismiss this textfield:
Don't forget, you're here forever.
Re: Allow enter-key for confirming dialogs
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!
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.
Re: Allow enter-key for confirming dialogs
You can detect an element being focused by listening to https://lua-api.factorio.com/latest/eve ... _gui_click, it works for textfields too.
Re: Allow enter-key for confirming dialogs
This just got added for 0.17.57, thanks guys! (Can be moved)