Search Unity

Question How to disable scroll wheel behavior in a TMPro Input Field?

Discussion in 'UGUI & TextMesh Pro' started by Superrodan, Apr 9, 2023.

  1. Superrodan

    Superrodan

    Joined:
    Nov 10, 2013
    Posts:
    10
    I am using a TMPro Input Field in place of a TMPro_Text element. This is because I need players to be able to copy and paste the text I output to it. So, I created a "read only" input field. I believe this is best/only practice for a text output that the player can copy bits and pieces of the text from.

    However, this particular text box has some additional requirements. It must scale the text placed in the box to fit in a certain area. With a TMPro_Text element this is super easy. I thought it would be just as easy with the input field too, because I noticed its using a TMPro_Text element in the "Text Component" field.

    Unfortunately, changing settings in that element did not work. They would reset on their own at runtime. The only way I managed to get it to work how I wanted was to have the "Input Field Line Type" set to Multi Line Submit, because without that on, my text box was not truncating the text, or scaling it properly.

    It's almost all entirely working. However, there is one small quirk.

    With the settings I'm using, if the player mouses over the text and scrolls down with their mouse wheel, the text scrolls up. This is even though it all easily fits in the window. It looks like this.
    textscroll.gif

    Is there any way to disable this scrolling? Everything is working as I would like other than that.
     
  2. Superrodan

    Superrodan

    Joined:
    Nov 10, 2013
    Posts:
    10
    I ended up switching to a Legacy Input Text Field. It did not have the same bug.