- Home /
Cannot hide keyboard on Android InputField
I am developing a chat app with Unity using uGUI. There is an InputField for the user to type in. The expected behaviour is
If the user presses OK or check mark button on the keyboard (I am using Google keyboard), send the message
If the user tap outside the keyboard, hide the keyboard
But both actions result to the same event which is End Edit. Is there anyway to differentiate these two actions.
Perhaps you could use the InputEdit.onValueChanged event ins$$anonymous$$d. But if you have a use case where they could click the edit field, not change anything, and hit O$$anonymous$$ (to say use a default value), then that wouldn't work. $$anonymous$$aybe InputEdit.wasCanceled could be tested ins$$anonymous$$d, but I don't know what will cause that flag to be set. You might also be able to override the $$anonymous$$eyPressed() method to set a flag indicating if the $$anonymous$$eyCode.Return or $$anonymous$$eyCode.Tab keys were pressed.
@Supernat Thank you very much for your suggestion. However, looking into InputField code here
This class relies on TouchScreen$$anonymous$$eyboard to handle the input. TouchScreen$$anonymous$$eyboard doesn't tell us much about what is happening, just only when the user is done with the keyboard (tapping okay or outside are translated to 'done'). I don't know when wasCanceled is set either, and $$anonymous$$eyPressed() seems to work only on desktop platforms
Your answer
