- Home /
How to detect "Cancel" vs. "Enter" on iOS Inputfield
Hi,
I have an input field. When EndEdit is fired, on PC I detect whether it was an actual 'submit' (vs. clicking outside the inputfield) by checking for the Return Key being down. This doesn't work on iOS, for obvious reasons.
Is there a way to detect when EndEdit is fired whether the user has actually submitted the text or pressed 'cancel' in their mobilekeyboard. This is using the built in InputField, not firing creating my own TouchKeyboard
--Sam
Answer by rodeowild · Feb 07, 2020 at 04:19 PM
Same question. InputFiled.isfocused
was my first guess but this is false in both click off and enter pressed scenarios.
Edit: I found a reasonable workaround here: https://answers.unity.com/questions/938556/how-to-prevent-input-field-firing-end-edit-on-chan.html
essentially saving focus state from the previous frame and using it to determine whether the method of end edit was enter vs clicking off of the field. Seems like this should really be its own event though.