How can I stop InputField focus/selection from activating device's native keyboard?
I'm developing a Daydream application that uses the GVR keyboard for text input. I'd also really like to use Unity's native InputField
so that I can take advantage of its many features, such as caret blinking. The problem is that InputField
by default will always try to open the device's native keyboard when the input field is selected/activated/focused. That means that in VR, the 2D keyboard pops up on screen anytime an InputField
is selected, which is a total blocker.
I've tried creating my own sub-class of InputField
, but the best I could do was immediately hide the device-native keyboard after it was activated. This would result in an undesirable flicker on the screen. Here's what that code looked like, for reference:
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class DaydreamInputField : InputField {
protected override void LateUpdate() {
base.LateUpdate();
if (m_Keyboard != null && m_Keyboard.active) {
m_Keyboard.active = false;
}
}
}
What I really need is a way to either tell the InputField
to not open the keyboard or a way to set TouchScreenKeyboard.isSupported
to false
(or something along those lines). Here are the lines of code I'm looking at:
if (TouchScreenKeyboard.isSupported)
{
if (Input.touchSupported)
{
TouchScreenKeyboard.hideInput = shouldHideMobileInput;
}
m_Keyboard = (inputType == InputType.Password) ?
TouchScreenKeyboard.Open(m_Text, keyboardType, false, multiLine, true) :
TouchScreenKeyboard.Open(m_Text, keyboardType, inputType == InputType.AutoCorrect, multiLine);
}
else
{
Input.imeCompositionMode = IMECompositionMode.On;
OnFocus();
}
If that first if
block was just useKeyboard && TouchScreenKeyboard.isSupported
(or something like that) and useKeyboard
was a public setter, that would be awesome!
I have similar problem,
Oculus GO keeps displaying a text field at the very bottom of my game when I focus one of the Text$$anonymous$$eshPro Input (it still does the same with the Unity default InputField).
Often in VR we will have virtual keyboards and will need to reuse the exiting text components for text selection, carrets etc. but suppress them from opening the native keyboards.
:( +1
Answer by Bunny83 · Feb 15, 2018 at 04:15 AM
I barely used the new UI system. However it looks like the Input field actually has a setting to disable the mobile input:
This is meant to hide the input that sits on top of the native keyboard. I'm trying to hide the ENTIRE keyboard. Thanks for the reply, though!
Your answer
![](https://koobas.hobune.stream/wayback/20220612152640im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
InputField keyboard hide suggestion 0 Answers
Keyboard not opening when I am trying to shift to next input field through script 0 Answers
Input keys not working ! please help me,Can't use input keys ! please help me ! 0 Answers
Handling Multiple U.I. Input Fields 0 Answers
Is there a way for inputfields to follow keyboard when i select them ? 0 Answers