Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[SOLVED] How to disable mobile keyboard for InputField?

Discussion in 'UGUI & TextMesh Pro' started by Cromfeli, Feb 23, 2016.

Thread Status:
Not open for further replies.
  1. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    202
    [SOLVED]
    I have my own simplified keyboard for mobile platforms, but on desktop I would like to let user still utilize keyboard. Now I have encountered difficulty on disabling the mobile keyboard when input field is selected.

    I tried many approaches for my customized InputField such as setting the:

    m_Keyboard = null;

    But it does not effect as the m_Keyboard is checked on every late update and overwrite the value.

    What is the best approach to disable mobile keyboard for a specific InputField? (Just to clarify I would like to disable it only for one specific InputField).

    Reference:
    [old link removed]

    [Solution]:
    Code (CSharp):
    1.     protected override void Start()
    2.     {
    3.         keyboardType = (TouchScreenKeyboardType)(-1);
    4.         base.Start();
    5.     }
    For the custom input field, thanks @friuns3 for advice!
     
    Last edited by a moderator: Dec 8, 2021
  2. eubrunomiguel

    eubrunomiguel

    Joined:
    Nov 11, 2015
    Posts:
    9
    How did you do that? How do I config it?
     
  3. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Think he created his own class, which inherits from InputField and added the lines you see there.
     
  4. FaberVi

    FaberVi

    Joined:
    Nov 11, 2014
    Posts:
    145
    How do I implement this part of code?
     
  5. abertrand

    abertrand

    Joined:
    Dec 7, 2015
    Posts:
    29
    This is what your input field should become. Then use this as your input field component

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. public class InputFieldWithoutKeyboard : InputField
    5. {
    6.     protected override void Start()
    7.     {
    8.         keyboardType = (TouchScreenKeyboardType)(-1);
    9.         base.Start();
    10.     }
    11. }
     
    CyborgGames, Cromfeli and FaberVi like this.
  6. markgrossnickle

    markgrossnickle

    Joined:
    Aug 21, 2017
    Posts:
    32
    I tried this and it works in the editor but fails in MixedReality UWP.

    I get:
    OverflowException: Value was either too large or too small for a UInt32.
     
    mdangalan likes this.
  7. arnaldoGaroto

    arnaldoGaroto

    Joined:
    Feb 3, 2013
    Posts:
    22
    making the inputfield non-interactable fixes the loop
     
    CrandellWS and Cromfeli like this.
  8. Gin2004

    Gin2004

    Joined:
    Dec 12, 2018
    Posts:
    3
    So I tried this and I got the virtual keyboard to disable... but when I use my external device (Paired Bluetooth laser scanner) nothing inputs into the InputField. It's almost like I cannot select it or keep it active. Anyone else had this specific problem? I'm on Unity 2019.2.17f1 btw.
     
  9. Evercloud

    Evercloud

    Joined:
    Apr 29, 2013
    Posts:
    15
    Just in case somebody still needs this piece of information, I used the "hide soft keyboard" and "hide mobile Input" in control settings of the input in the inspector and it worked like a charm.
     
Thread Status:
Not open for further replies.