- Home /
Touch Screen Keyboard Test in Editor
I am building for a tablet with a touchscreen (HP Pro X2, to be specific) and I need my input fields to pop up a touchscreen keyboard when the user clicks on these fields. So right now, I'm doing it in my update function and it looks like:
if(Initials.GetComponent<InputField>().isFocused)
{
keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
if(keyboard.active == true)
{
Debug.Log("It would be open");
}
else if (keyboard.active == false)
{
Debug.Log("It would not be open");
}
}
It returns that "It would not be open" and I'm not sure exactly why. Am I using the touchscreen incorrectly? Or is there no way for me to accurately test in my editor on PC? I saw the other post that was similar to this one and they used something out of System.Diagnostics, but that it was unreliable and this needs to be reliable.
Anything helps!
Answer by Bubinga_Studios · Aug 01, 2018 at 04:00 PM
Input Fields should automatically pop up a touchscreen keyboard. I think if you are trying to create a touchscreen keyboard, you should just use the Input Field UI object. (You can find it by Right Click on Hierarchy > UI > Input Field) This works both on computer and on all mobile platforms. You can see when it has been edited or finished editing (clicked done button or exited input field) but I am not 100% sure on how to see when it is opened up.
If I didn't answer your question correctly, or you do not want to use this method, let me know by sending me more details. Hope this helps!
Hey there, thanks for the quick reply! Yeah so I already have the input field on there and actually built a phase 1 demo for the target platform. And using the touchscreen for tapping buttons and whatnot worked fine. But if you tapped on an input field, no keyboard popped up. So I was assu$$anonymous$$g that this was something that I was going to have to address with code. But now that I think about it, the tablet has a little protective case that has a keyboard on it, so is it possible that having that external keyboard in the case would override the touchscreen keyboard? Hope that better explains the issue
Part of the issue is that my target platform (this is part of an internship) is this HP Pro X2 which runs Windows 10 (or at least a version of it) on this tablet/computer hybrid. I went back and made sure the touchscreen on the device was enabled, works for going on the internet and whatnot, but still doesn't work in the Unity app. So it IS an issue that I will need to address
Oh I see! I am not too familiar with the HP Pro X2. I did see that, but I am not sure on it's functionalities. I am used to Apple and Android. If it has an external keyboard, it will probbably override it. Does the HP Pro X2 include a built in touchpad? And if so, does Unity support this? If it doesn't, you can build a touchscreen keyboard for it. If you need help, I can search more into it. Sorry for not understanding at first haha. Hope your issue is resolved!
Yeah so like I was saying the HP does have a touchscreen included and you can use it for surfing the web and other things. But when I try to click on the input field on the tablet, nothing happens. It actually puts a cursor in the input field like its ready to receive text, but I obviously have nothing to input with. How would I go about building a touchscreen and what kind of impact would that have on functionality and speed?
Answer by Jewelry_shun · Sep 20, 2021 at 11:50 AM
Hello can you help me to, i creating an typing game and i want the keyboard to show even without an input field is it possible?,Hello, can you help me to, i creating at typing game and i want the keyboard show even without an input field, is it possible to pop up?
Answer by Dalton-Lima · Jan 03 at 06:13 PM
For posterity.
Without testing, but according to the documentation on MobileKeyboard you should also check TouchScreenKeyboard.visible
inside a Coroutine loop because you need to give a few frames in order for the keyboard to scroll up on the screen and be ready to go.
TouchScreenKeyboard.Open() is called. TouchScreenKeyboard.active returns true. TouchScreenKeyboard.visible returns false. TouchScreenKeyboard.area returns (0, 0, 0, 0).
Keyboard slides out into the screen. All properties remain the same.
Keyboard stops sliding. TouchScreenKeyboard.active returns true. TouchScreenKeyboard.visible returns true. TouchScreenKeyboard.area returns real position and size of the keyboard.
Your answer
Follow this Question
Related Questions
Script works in Game View, but not in build 0 Answers
Can I know why I can't control volume of audiomixergroup without exposing parameters? 0 Answers
Touch interface with alternative keyboard in Unity3D? 1 Answer
Changing default animation type to Humanoid via script 1 Answer
Does unity editor support win8 pen and touchscreen input 1 Answer