Search Unity

Keyboard not switching

Discussion in 'UGUI & TextMesh Pro' started by unnanego, Mar 9, 2019.

  1. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    I have several TMP Input fields. One of them is standard input type with a phone pad keyboard, the other one is email, the third one is multiline newline with standard keyboard. If I switch from the third one to either of the first two the keyboard switches just fine, but if I switch between the first two the keyboard doesn't change. So, if I select the phone pad input field and then select the email input field the phone pad persists. I added a method to close the keyboard on deselect, but this changes nothing.
     
  2. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    the problem persists in 1.4.0....
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you provide me with a simple repro project to test with?
     
    unnanego likes this.
  4. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
  5. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    mmm?
    I think the problem is with multiline keyboard. I wrote a simple script that changes placeholder text to "" on select and changes it back at deselect and I set the telephone keyboard to standard. Now the placeholder disappears fine in all fields that are standard-single line, but when I switch from a single line input field to a multiline input field the placeholder in the latter disappears for a fraction of a second and then appears back. If I tap somewhere outside of input fields and then tap on the multiline input field the placeholder disappears as it should.

    And for some reason if I set the telephone input field to custom - phone pad, it stops working at all - tapping it doesn't do anything.

    Please, need some support on this, this is really annoying((

    Oh, and on Android the placeholder works fine, but Phone pad also doesn't work(
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Will I be able to reproduce these behaviors using the download linked above?

    What are the steps to reproduce this?
     
  7. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    You should.

    To reproduce: create two input fields. One of them should be standard - single line, the other one - standard - multiline. On both fields on OnSelect and OnDeselect we have a script. OnSelect changes the placeholder to "", OnDeselect changes it back:

    Code (CSharp):
    1.     public GameObject[] fields;
    2.     public GameObject[] placeholders;
    3.     public string[] labels;
    4.  
    5.     public void SetPlaceholder(int i)
    6.     {
    7.         placeholders[i].GetComponent<TextMeshProUGUI>().text = "";
    8.     }
    9.  
    10.     public void ResetPlaceholder(int i)
    11.     {
    12.         placeholders[i].GetComponent<TextMeshProUGUI>().text = labels[i];
    13.     }
    So the script works well in editor and on android, but on iOS when switching between single line input fields and multiline input fields the placeholder doesn't disappear. It does disappear if tapping on the multiline field from no focus on any input fields.

    Previously I had a different problem - one of the fields was standard - multiline, the other one was Custom - Phone Pad - No Validation and another one standard-one line. If you switched between standard-one line and Multiline - the keyboards switched properly (phone pad to standard keyboard), but when trying to switch between single line and phone pad - the first open keyboard remained when switching (if at first you select phone pad, switching directly to single line doesn't give you the standard keyboard, the phone pad remains).