Search Unity

Question Is it possible to adjust layout when soft keyboard appears

Discussion in 'UI Toolkit' started by Alexis-Dev, Jun 7, 2021.

  1. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    Hello everybody,

    I want to know if is it possible to adjust layout when soft keyboard appears (android and iOS keyboard)?

    Actually, the keyboard hide the input field on the bottom screen and I want to have it on the top of the keyboard like:


    Someone have an idea?

    Best,
    Alexis
     
    Mj-Kkaya, Midiphony-panda and Nexer8 like this.
  2. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    Not tried yet, but here's a hint :
    https://docs.unity3d.com/ScriptReference/TouchScreenKeyboard.html
    "TouchScreenKeyboard.visible and TouchScreenKeyboard.area should be used to determine if the keyboard is being shown (activated) and what portion of the screen is using."

    You should be able to reposition the TextField from the code, when you know that the user is editing it : I have no idea for this part though. :oops: (I don't see yet anything specific in the TextField doc or in the list of available events)
     
  3. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    Hello,

    This is the technique I use with UGUI, but it's not optimal. Btw TouchScreenKeyboard.area don't work on Android and TouchScreenKeyboard don't have hide and visible event...

    I hope a better solution come with UI Toolkit!

    Best,
    Alexis
     
  4. cpalma-unity

    cpalma-unity

    Unity Technologies

    Joined:
    Nov 30, 2020
    Posts:
    110
    Hi. Yes, this is definitely something we would like to have in the future. Right now, the way to go is using
    TouchScreenKeyboard.visible
    and
    TouchScreenKeyboard.area
    whenever possible and adjust the layout according to those values. We know it's not ideal, but we will look into a more integrated solution eventually :)
     
  5. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    Great news!
    Thx :)
     
  6. unity_48CEDB9C94B428023987

    unity_48CEDB9C94B428023987

    Joined:
    Sep 28, 2021
    Posts:
    8
    Any updates on this topic? Maybe with the latest versions of Unity?
    Thanks in advance! :)
     
  7. cnsjjj

    cnsjjj

    Joined:
    Aug 13, 2022
    Posts:
    35
    Any updates? Thanks for the suggestion!
     
  8. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    179
  9. RahmatAli_Noob

    RahmatAli_Noob

    Joined:
    Sep 13, 2022
    Posts:
    74
    Has Anybody find the Solution for the Keyboard height when it's Open in Android and IOS?
    Thanks In Advance.
     
  10. dominikkoller

    dominikkoller

    Joined:
    Jul 26, 2018
    Posts:
    20
    +1
    Is this possible by now?