Search Unity

Question The touch on the button does not work correctly when the InputField is selected

Discussion in 'UGUI & TextMesh Pro' started by francuzfr, Jan 22, 2024.

  1. francuzfr

    francuzfr

    Joined:
    Dec 21, 2020
    Posts:
    1
    Hello!

    We recently switched to a new input system and we had a problem with touching a button when the InputField was selected on a mobile devices. The button event fired twice.

    For debugging, I made a MonoBehavior with interface implementations of IPointerClick, IPointerDown, IPointerUp, IPointerEnter and IPointerExit.

    Code (CSharp):
    1. public sealed class Test : MonoBehaviour, IPointerClickHandler, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler
    2.     {
    3.         public void OnPointerClick(PointerEventData eventData)
    4.         {
    5.             Debug.Log("Click");
    6.         }
    7.  
    8.         public void OnPointerDown(PointerEventData eventData)
    9.         {
    10.             Debug.Log("Down");
    11.         }
    12.  
    13.         public void OnPointerUp(PointerEventData eventData)
    14.         {
    15.             Debug.Log("Up");
    16.         }
    17.  
    18.         public void OnPointerEnter(PointerEventData eventData)
    19.         {
    20.             Debug.Log("Enter");
    21.         }
    22.  
    23.         public void OnPointerExit(PointerEventData eventData)
    24.         {
    25.             Debug.Log("Exit");
    26.         }
    27.     }
    When clicked, under normal conditions, events are executed in the following order: Enter, Down, Up, Click, Exit.

    upload_2024-1-22_18-36-22.png

    But when the InputField is selected, in LogCat we see the following: Enter, Down, Up, Click, Down, Up, Click, Exit.

    upload_2024-1-22_18-37-43.png

    That is, with the InputField selected, Down, Up and Click are triggered when I pressed the button and when I released the button. We see this only in the new Input System.

    Please tell me why this behavior occurs? And how can this problem be solved?

    Unity version we are working on: 2022.3.11f1
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    698
    Hello, sounds like you found a bug! Can you report it inside Unity (Help > Report a bug) so it can be investigated and fixed? Thanks!
     
    denisbut1212 likes this.