How do i stop InputField Submitting twice? - When "Enter" and again when it loses focus

Basically the title, I’m working with an input field and the Submit action is called when enter is pressed, thanks to the checkbox setting on it. However, I would really like it to not call Submit a second time when the user then clicks on something else

Is this possible?

Ideally: hitting enter would cause the inputfield to lose focus (i tried to do this, but it caused a loop)

EDIT: looks like this might have gotten fixed in the latest GUI beta

InputField submit stuff seems inconsistent. I just turned it off and listened to input the old fashion way.

yea i was going to ask what version as we did ALOT to input field for f1

I want the solution to this question too. I only want to fire off an event when “Enter” is pressed. I don’t want to do anything when InputField is loosing focus. Can anyone tell me how I can distinguish between these two with EndEdit event?

Thanks

you’ll need to create your own class derived from InputField and override both KeyPressed (to send the event when enter is pressed) and DeactivateInputField to not send the event.

or just override KeyPressed and send a different event instead of the submit event and dont listen for submit.

I ended up doing this inside the EditEnd callback

if(EventSystem.current.alreadySelecting == true) return;

So if the object is deselected and another object is being selected the rest of the code doesn’t run. This is working just fine :slight_smile:

1 Like

I don’t think that creating a class derived from InputField and overriding those two methods would work since DeactivateInputField is not marked as virtual and KeyPressed is just protected…