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. Dismiss Notice

How to disable scrollbar / keyboard interaction

Discussion in 'UGUI & TextMesh Pro' started by jdoran, Jan 28, 2017.

  1. jdoran

    jdoran

    Joined:
    Nov 4, 2014
    Posts:
    4
    Searching the forums, I found a lot of people asking for the ability to change scrollbars using the up/down arrow keys. I want the opposite.

    I am using the arrow keys for the vertical axis, and really don't like seeing the scrollbar change when I move. I have enough control using the mouse.

    Looking at the input manager, the only thing using the arrow keys was vertical. In particular "Mouse Scrollwheel" was NOT bound to these keys. Yet the up/down arrow keys are changing the scrollbar.

    Now you might note that the control containing the scrollbar has focus. But that doesn't stop movement (the character controller reads the axis itself). And I don't object to the focus on a frequently used text control. Needing to manually refocus will be a distraction.

    Hopefully we don't have a case of a control hard-coding values, and bypassing the input manager.

    If there is no easy way of changing this, would it be possible to subclass the scrollbar and disable this behaviour? (I'm not British, I just use MonoDevelop)
     
    wlwl2 likes this.
  2. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    I was JUST trying to figure out this very thing myself. I don't want my scrollrect and scrollbar moving while the player is moving.
     
  3. jdoran

    jdoran

    Joined:
    Nov 4, 2014
    Posts:
    4
    I downloaded the source for the Scrollbar and Scrollrect off of Bitbucket. I was unable to get Scrollbar to build (after changing its name) due to some problem with SetPropertyUtility being unaccessable due to protection. Not sure about that, as both classes are in the same namespace. So I was unable to modify the Scrollbar source, however I do not see any direct access to the input manager.

    The two users of the Vertical axis are the FirstPersonController (or Third if applicable), and the EventSystem. Giving the event system another vertical axis got rid of the erroneous scrolling. But of course that could have other consequences. But right now I'm not sure what I would want to be handling the up/down arrow keys, other than the FirstPersonController.
    I believe that the EventSystem is creating scroll events from the vertical axis.

    So that might be a workaround.

    Another was to ensure that another control had focus. In my case I put focus on an InputField. In my case, I have a listener for onEndEdit, so I was able to refocus the control after the user types return.

    input.ActivateInputField();
    input.Select();
    input.text = "";

    And that was another workaround, which for now seems OK.

    But I am thinking of opening a bug on this. While design issues are not bugs, I'm not sure that this was an intentional decision by Unity. It smacks of an oversight. Too many things using a single axis conflicts with the philosophy of letting us configure just about anything.
     
  4. PedrasWebAvenue

    PedrasWebAvenue

    Joined:
    May 2, 2019
    Posts:
    1
    Hey, just figured this out and wanted to leave it here, may help someone else.

    If you don't use the Input Axes, more specifically the horizontal one (I'm making a mobile game, so never use it) you can just delete the keys from it by going:

    Edit -> Project Settings -> Input -> Axes -> Horizontal and delete the strings at "Negative Button" and "Positive Button"
     
  5. Lazy_Evaluation

    Lazy_Evaluation

    Joined:
    Nov 16, 2019
    Posts:
    15
    You can also set the Navigation value to "None". This fixes the problem without modifying your input axes.
     
    huulong and SanyaBane like this.