How to trigger the OnEndEdit event for a InputField (e.g. by a button click)?

I have a InputField and a button to submit it in a scene with new UI.
Via Inspector, the InputField’s OnEndEdit event is setup to call a method.

Now I would like the button to fire the OnEndEdit event of the InputField somehow.
Is that possible? I couldn’t figure out a way to do that, but I wasn’t using the new UI yet.

I know there are workarounds but I’d like to learn using the Event System, too.

Just posting because of your Avatar x-D
And because I have the same question, which is why I found this thread. Did you find a solution yet?

1 Like

…ok, found it: just as with emulating button clicks you can invoke all listeners:

inputField.onEndEdit.Invoke(myNewText); // this also seems to update inputField.text, and trigger OnValueChanged

3 Likes

Was searching for this for almost an hour, thanks once again. It turned out to be quite simple… :smile:

1 Like

lol. What a strange coincidence! Do you all have birthdays in April, too? :wink:

I was kind of hoping that just setting the values via script would trigger the OnEndEdit but I guess that only works with OnValueChange. FYI, Invoking OnEndEdit doesn’t appear to be updating values for me :-(.