Page 1 of 1

on_gui_confirmed for textfields - works or does not?

Posted: Sat Nov 23, 2024 8:04 am
by hgschmie
I have seen viewtopic.php?t=73372, which states "on_gui_confirmed can't work with text boxes because enter is already reserved for adding newlines to the text box."

However, there is https://lua-api.factorio.com/latest/eve ... _confirmed, which literally says "Called when a LuaGuiElement is confirmed, for example by pressing Enter in a textfield." and there is https://lua-api.factorio.com/latest/cla ... on_confirm which states "Whether this textfield loses focus after defines.events.on_gui_confirmed is fired."

However, I have yet to manage seeing the on_gui_confirmed event being fired from a text field in my code.

Am I doing something wrong? Is that documentation incorrect and the forum post correct? Are there any working code examples of "press <ENTER> in a text field, receive on_gui_confirmed event"?

Grateful for any pointers.

Re: on_gui_confirmed for textfields - works or does not?

Posted: Sat Nov 23, 2024 5:19 pm
by s6x
I think the issue is that a text field ("textfield") and a text box ("text-box") are different things. You can press enter to confirm a textfield, because it is one line, but pressing enter in a text-box just inserts a newline, because it is multiple lines. This interpretation is seemingly confirmed by this GUI documentation page, which lists on_gui_confirmed as relevant for textfield but not text-box: https://lua-api.factorio.com/latest/con ... tType.html

(I haven't tested this myself, though, so I don't know if textfield is working properly)

Re: on_gui_confirmed for textfields - works or does not?

Posted: Sat Nov 23, 2024 7:16 pm
by hgschmie
Hi,

Thanks for the quick answer! What I am looking at is a textfield and I can't seem to receive the event when return is pressed. That is my confusion. :-) There is no text-box anywhere.