Search Unity

TextMesh Pro How to find out if the keyboard is shown for TMP_Input Field

Discussion in 'UGUI & TextMesh Pro' started by GadOleg, Oct 8, 2021.

  1. GadOleg

    GadOleg

    Joined:
    Nov 13, 2019
    Posts:
    58
    Hello on InputField, it was possible to check whether the keyboard was shown or not using touchScreenKeyboard!= null. But how to check if the keyboard is shown at TMP_Input Field?
     
  2. GadOleg

    GadOleg

    Joined:
    Nov 13, 2019
    Posts:
    58
    Thank you for responding.

    But I will explain what my task was: When entering text in the field, sometimes the keyboard overlaps the input field itself, which is inconvenient. To fix this problem, I lift the input field above the keyboard. In order to raise exactly the field in which the input occurs, I wanted to check who owns the keyboard. Not knowing this, I went out another way:
    Code (CSharp):
    1. void Update()
    2.     {
    3.         if (iOpenKeyBoard)
    4.         {
    5.             if (TouchScreenKeyboard.visible)
    6.             {
    7.                 float HC = MobileUtilities.GetKeyboardHeight(false);
    8.                 Debug.Log(" <color=yellow>" + HC + "</color> ");
    9.                 float delta = HC - BottomOld;
    10.                 if (delta > 0)   RT_SizePanel.anchoredPosition = new Vector2(0f, delta);
    11.             }
    12.         }
    13.     }
    The iOpenKeyBoard variable is updated in the events shown in the figure.
    Code (CSharp):
    1.     public void ShowKeyboard(bool show)
    2.     {
    3.         iOpenKeyBoard = show;
    4.     }
    Maybe my solution is not the best, but it has worked
     

    Attached Files: