on_gui_confirmed for textfields - works or does not?

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
hgschmie
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Feb 06, 2024 5:18 am
Contact:

on_gui_confirmed for textfields - works or does not?

Post 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.
s6x
Inserter
Inserter
Posts: 26
Joined: Fri Nov 15, 2024 8:22 pm
Contact:

Re: on_gui_confirmed for textfields - works or does not?

Post 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)
User avatar
hgschmie
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Feb 06, 2024 5:18 am
Contact:

Re: on_gui_confirmed for textfields - works or does not?

Post 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.
Post Reply

Return to “Modding discussion”