Search Unity

TextMesh Pro Mouse wheel on multiline input field with no scrollbar 'hangs' input field, stops event firing.

Discussion in 'UGUI & TextMesh Pro' started by Peeling, Dec 16, 2019.

  1. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    443
    I've been trying to track down an intermittent problem with my app for ages and finally figured it out: if you create a multiline TMP input field with no scrollbar and use the mouse wheel with the mouse over the input field, the caret will stop flashing (will stay on or off depending what it was at the time). If you then click off the input field, the OnEndEdit event is not fired.

    Am going to go digging in the source folder as this is a massive issue for the app I'm creating. Will report back if I find a fix.

    EDIT: Found it. Pretty clear cut actually:

    If you go look in TMP_InputField.cs, you'll find this method:

    Code (CSharp):
    1.  public virtual void OnScroll(PointerEventData eventData)
    In this method there's a commented line:

    Code (CSharp):
    1.             // Disable focus until user re-selected the input field.
    2.            m_AllowInput = false;
    The problem is, the end-edit cleanup activity, including dispatching the OnEndEdit event, is gated behind m_AllowInput being true. So if the last thing you do before clicking off a multi-line input field is scroll the mouse, you won't get the OnEndEdit callback.
     
    Last edited: Dec 16, 2019
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I was able to reproduce the above issue and have resolved it.

    While looking at this, I also uncovered that when using a script with OnScroll Event, the Input Field incorrectly scrolls when in Single Line mode. This has also been resolved.

    I also modified the behavior where OnEndEdit is not called when using a Scrollbar assigned to the Input Field. Thoughts on this part?
     
  3. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    443
    >I also modified the behavior where OnEndEdit is not called when using a Scrollbar assigned to the Input Field. Thoughts on this part?

    Sorry, didn't see this reply earlier. I mentioned 'no scroll bar' in the original report but as it turned out it wasn't related to the lack of scroll bar, just the status change when using the scroll wheel. If there were other problems I never encountered them :)