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

Select Next Input Field on Mobile

Discussion in 'UGUI & TextMesh Pro' started by cbauman, Feb 21, 2016.

  1. cbauman

    cbauman

    Joined:
    Aug 29, 2011
    Posts:
    17
    For an Android project of mine, I have a list of input fields that I would like to be able to navigate while keeping the IME keyboard open. I thought the navigation property on input fields would result in this functionality but it shows the "Done" button instead; which closes the keyboard and requires you to touch the next field manually.

    Screenshot_2016-02-22-00-57-55.png



    The Quizlet app is an example of what I'm looking for. In landscape mode it shows the "Next" button instead of "Done" which keeps the keyboard open and navigates to the next input field.

    Screenshot_2016-02-22-00-59-15.png



    And in portrait mode, in Quizlet, you can select different input fields with the keyboard open, whereas in Unity, if you touch outside the keyboard, it closes.

    Screenshot_2016-02-22-00-59-36.png


    I know it has something to do with IME_ACTION_DONE and IME_ACTION_NEXT referenced here: http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html
    but I'm not sure how to utilize that info in Unity. Can anyone recommend a solution?

    As a last resort, I'll use the "End Edit" callback to focus the next input field but it's a pretty hacky solution. because you can see the keyboard quickly close and open again.
     
    Last edited: Feb 22, 2016
    Fotal likes this.
  2. chriszul

    chriszul

    Joined:
    Feb 13, 2018
    Posts:
    33
    Does anyone have a solution for this? It seems like it should be available in the touch keyboard API but I don't see anything in the docs.
     
  3. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,845
  4. Fotal

    Fotal

    Joined:
    Apr 9, 2019
    Posts:
    38
    Keyboard provided via class TouchScreenKeyboard does not meet the needs of mobile games at all.

    The problems I faced:
    1. Keyboard can overlap the input field. This can be handled in a complex way in Unity.
    2. There is no way to navigate to the next fields.
    3. If you set TouchScreenKeyboard.hideInput = true and in your TMP_InputField.onFocusSelectAll also true, then when you selected the InputField you see Double selection: in your Unity app and on keyboard Input panel.
    4. Not intuitive handling of keystrokes on the keyboard, no events.

    I would also like to draw Unity attention to this issue.
     
  5. lixi_x

    lixi_x

    Unity Technologies

    Joined:
    May 5, 2021
    Posts:
    9
    The field navigation can be implemented with below sample script:
    Code (CSharp):
    1. sourceField.onEndEdit.AddListener(delegate{CheckDone(sourceField, targetField);});
    2. void CheckDone(InputField sourceField, InputField targetField)
    3.     {
    4.         if (sourceField.touchScreenKeyboard.status == TouchScreenKeyboard.Status.Done)
    5.             // do something such as navigate to target field : targetField.Select();
    6.     }
    It allows you to go to target field and keyboard doesn't show and disappear. Please note that currently tmp_inputfield doesn't expose touchScreenKeyboard property like UI inputfield does but it will be included in the next release.