I’ve tried searching for the answer and it seems like it used to be an option but somewhere along the line Unity pulled it. Is it still possible?
I’m not sure I understand the question (which might just be due to my ignorance).
If you’re trying to listen for submit events from the InputField, there’s an onEndEdit field of type SubmitEvent that can be edited from the inspector (and presumably you could add listeners through code through the AddListener function).
If you’re trying to get the InputField itself to respond to some arbitrary event elsewhere in your game as if it were a submit event, well…onSubmit() is just a function, so I would imagine you can just call it (either from code or through Unity’s event system).
onEndEdit is called also when user clicks anywhere else, which is not the same as submit. The InputField desperately needs a way to subscribe submit events.
What exactly is a “submit”?
On PC it’s usually enter (there’s a “Submit” input button defined in StandaloneInputModule) and on Android it’s when you press the “Done” button or whatever in the onscreen keyboard.
Bump… sorry for resuming this old post, did anybody found a solution to this?
@LorenzoNuvoletta - Hi there, I’m bit curious, what solution exactly?
@Antistone gave example how it’s possible to listen to end of editing in InputField, but it really does also mean clicks outside input field.
But if you need some submit button then why not just add a button, then when you press it, make it read contents of input field and do whatever you need with that data?
AFAIK there is no specific “submit button” for input field for above mentioned reason, and any button should do it for this task if I’ve understood it correctly, because there is no specific “submit” thing… just have a method that is triggered by some button and then it taps to inputField’s text.
And I gave an example on why OnEndEdit isn’t enough. It’s conventional to press enter on PC or press the done button on Android to submit. OnEndEdit is not the same, because it’s also called when you click outside the field.
Is there a way to check if Focus was Lost, example: in kissUI you have OnFocusReceived() / OnFocusLost().
As long as OnFocusLost() is raised before OnEndEdit(), as least you can tell if the user wanted to Cancel any input Edits.