Search Unity

Scrolling an inputfield

Discussion in 'UGUI & TextMesh Pro' started by holyjewsus, Apr 25, 2015.

  1. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    I want to scroll an input field, code below just watches for scroll events and calls process event on the input field then generates a new keyboard event with the correct key... this correctly moves the caret inside the input field but does not scroll the input field like really pressing the up and down keys does, whats the difference?

    Code (CSharp):
    1.     #region IScrollHandler implementation
    2.  
    3.     public void OnScroll (PointerEventData eventData)
    4.     {
    5.         if (eventData.IsScrolling())
    6.         {
    7.             if (eventData.scrollDelta.y < 0)
    8.             {
    9.                 var ev = Event.KeyboardEvent("up");
    10.                 inf.ProcessEvent(ev);
    11.  
    12.             }
    13.             else{
    14.                 var ev = Event.KeyboardEvent("down");
    15.                 inf.ProcessEvent(ev);
    16.  
    17.             }
    18.         }
    19.     }
    20.     #endregion
     
  2. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    solution was to use reflection to call UpdateLabels() after moving the caret.
     
    SimonDarksideJ likes this.
  3. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    I'd log an issue to fix that bug. If it's needed it should be public and not require reflection.
    Log it using the Unity bug reporter in the editor as an enhancement.
    Nod @phil-Unity