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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Keyboard Input field not showing on initial launch

Discussion in 'iOS and tvOS' started by Funflow, May 14, 2015.

  1. Funflow

    Funflow

    Joined:
    Feb 16, 2015
    Posts:
    1
    IMG_0110.PNG IMG_0111.PNG

    As you can see on screenshots, Apple's keyboard does not show input field on initial launch.
    This bug disappears after relaunch.
    My Unity version is 4.6.4f1 and text input is implemented by NGUI UIInput.
     
  2. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    If you are still seeing this on a recent Unity version, please file a bug and attach the project to it. Please paste the bug id here. Thanks :)
     
  3. MikePanoff

    MikePanoff

    Joined:
    Apr 29, 2015
    Posts:
    20
    I can confirm this bug is still happening in Unity 5.1.2 on iOS. I did not test android. It works fine in the editor because there is no mobile keyboard widget.

    I tracked it down and here's what seems to be happening:

    Test Scene:
    Create a simple scene with 2 input fields InputField_0 and InputField_1

    Bug Repeat Case:
    1) Tap on InputField_0. The iOS keyboard comes up.
    2) BUG: Tap QUICKLY on InputField_1, the keyboard diappears and nothing has focus.

    Success Case:
    1) Tap on InputField_0. The iOS keyboard comes up.
    2) Tap on InputField_1 and HOLD YOUR FINGER there until the keyboard fully disappears.

    Assessment:
    It appears as if you fully need to wait for they keybaord to disappear before letting go of InputFiled_1 in order for the focus request to register. Otherwise, the closing of the mobile keyboard from the InpuField_0 will call the OnEndEdit() event for InputFiled_1

    Ideal Solution:
    Ideally switching between input fields would just keep the keyboard visible like it does on native implementations.

    Debug Info:
    Here is the call stack from the Unity generated XCode project for what is happening.

    I tap on InputField_0 and get this
    UnityEngine.Debug:Internal_Log(Int32, String, Object)
    UnityEngine.Debug:Log(Object)
    TableItem:OnClickCallback() (at /Users/mike/src/aj/hmm/Assets/TableItem.cs:37) //
    UnityEngine.Events.InvokableCall:Invoke(Object[])
    UnityEngine.Events.InvokableCallList:Invoke(Object[])
    UnityEngine.Events.UnityEventBase:Invoke(Object[])
    UnityEngine.Events.UnityEvent:Invoke()
    UnityEngine.UI.ButtonPress()
    UnityEngine.UI.Button:OnPointerClick(PointerEventData)
    UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData)
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    UnityEngine.EventSystems.TouchInputModuleProcessTouchPress(PointerEventData, Boolean, Boolean)
    UnityEngine.EventSystems.TouchInputModuleProcessTouchEvents()
    UnityEngine.EventSystems.TouchInputModuleProcess()
    UnityEngine.EventSystems.EventSystem:Update()

    (Filename: /Users/mike/src/aj/hmm/Assets/TableItem.cs Line: 37)

    I now tap on InputField_1 which takes focus away from InputField_0 and starts hiding the keyboard.
    TableItem:OnEndEditHandler() (at /Users/mike/src/aj/hmm/Assets/TableItem.cs:70)
    UnityEngine.Events.InvokableCall:Invoke(Object[])
    UnityEngine.Events.InvokableCallList:Invoke(Object[])
    UnityEngine.Events.UnityEventBase:Invoke(Object[])
    UnityEngine.Events.UnityEvent`1:Invoke(T0)
    UnityEngine.UI.InputField:SendOnSubmit()
    UnityEngine.UI.InputFieldDeactivateInputField()
    UnityEngine.UI.InputField:OnDeselect(BaseEventData)
    UnityEngine.EventSystems.ExecuteEvents:Execute(IDeselectHandler, BaseEventData)
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    UnityEngine.EventSystems.EventSystem:SetSelectedGameObject(GameObject, BaseEventData)
    UnityEngine.EventSystems.PointerInputModuleDeselectIfSelectionChanged(GameObject, BaseEventData)
    UnityEngine.EventSystems.TouchInputModuleProcessTouchPress(PointerEventData, Boolean, Boolean)
    UnityEngine.EventSystems.TouchInputModuleProcessTouchEvents()
    UnityEngine.EventSystems.TouchInputModuleProcess()
    UnityEngine.EventSystems.EventSystem:Update()


    .. that same click give focus to InputField_1 (note keyboard is still moving to hidden position)
    TableItem:OnClickCallback() (at /Users/mike/src/aj/hmm/Assets/TableItem.cs:37)
    UnityEngine.Events.InvokableCall:Invoke(Object[])
    UnityEngine.Events.InvokableCallList:Invoke(Object[])
    UnityEngine.Events.UnityEventBase:Invoke(Object[])
    UnityEngine.Events.UnityEvent:Invoke()
    UnityEngine.UI.ButtonPress()
    UnityEngine.UI.Button:OnPointerClick(PointerEventData)
    UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData)
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    UnityEngine.EventSystems.TouchInputModuleProcessTouchPress(PointerEventData, Boolean, Boolean)
    UnityEngine.EventSystems.TouchInputModuleProcessTouchEvents()
    UnityEngine.EventSystems.TouchInputModuleProcess()
    UnityEngine.EventSystems.EventSystem:Update()

    HERE IS THE BUG -- As soon as the mobile keyboard slides off screen to its hidden position, this call stack calls the OnEndEdit() event for InputField_1, taking focus away from InputField_1 and leaving nothing with foucs.

    TableItem:OnEndEditHandler() (at /Users/mike/src/aj/hmm/Assets/TableItem.cs:70)
    UnityEngine.Events.InvokableCall:Invoke(Object[])
    UnityEngine.Events.InvokableCallList:Invoke(Object[])
    UnityEngine.Events.UnityEventBase:Invoke(Object[])
    UnityEngine.Events.UnityEvent`1:Invoke(T0)
    UnityEngine.UI.InputField:SendOnSubmit()
    UnityEngine.UI.InputFieldDeactivateInputField()
    UnityEngine.UI.InputField:OnDeselect(BaseEventData)
    UnityEngine.UI.InputField:LateUpdate()
     
    Last edited: Aug 7, 2015
  4. MikePanoff

    MikePanoff

    Joined:
    Apr 29, 2015
    Posts:
    20
    I submitted a bug, it is Case 718407