I need to call a function when the keyboard is dismissed, and this (in Update) does not work:
if (TouchScreenKeyboard.Status.Visible && TouchScreenKeyboard.Status.Done) {
OnKeyboardDismiss();
return;
}
I don’t understand how TouchScreenKeyboard.Status is supposed to be used, and there is no sample code in the scripting docs. How do I detect when the keyboard is dismissed?
I found something like this in some sample code, but it doesn’t work either. Looks like there’s no way to get a reference to the current keyboard without opening it. If I do an Open on Start, it shows the keyboard, which is bad. But it doesn’t matter where I get the reference, it never returns Done or Canceled. Any help, or some more current sample code, would be greatly appreciated.
function Update () {
TouchScreenKeyboard keyboard;
theFocus = EventSystem.current.currentSelectedGameObject;
if (theFocus == null)
return;
keyboard = TouchScreenKeyboard.Open("");
if (keyboard.status == TouchScreenKeyboard.Status.Done || keyboard.status == TouchScreenKeyboard.Status.Canceled) {
OnKeyboardDismiss();
return;
}
I’m updating from an older project that used EZGUI where it correctly identified when the keyboard was dismissed. I’m trying to do the equivalent with TMPro and UGUI. I have some text input in a panel near the bottom of the screen, and that panel slides up when the keyboard appears. I need to know when the keyboard is dismissed so I can slide the panel back down to be able to see the top of it.
Did you have any luck getting an instance of the touchscreenkeyboard?
I tried the following, but still not able to get data from touchScreenKeyboard.status
I’m having a similar problem with the touchScreenKeyboard :(. I wanted to check if the currently selected input field’s keyboard is active so that I can turn on the keyboard’s caps lock key when it first pulls up. However, when I try:
if (inputField.touchScreenKeyboard.active)
{
Debug.Log("Woah! Your keyboard is showing!");
// Insert other logic here
}
I get a null reference exception. I keep googling “inputField.touchScreenKeyboard examples”, but I can’t find any examples on how you are supposed to initialize it.