How to disable scrolling with keyboard for UI scrollrect

Is there a way of disabling the scrolling of ScrollRect component on UI, as it’s a bit annoying to see the UI scrolls automatically when user presses wasd and at the same time looks at it. I knew it can be set to UI layer so user has to open the menu to manipulate the UI component, I just wonder if the UI can only be scrolled via dragging with mouse or hand controller.
Thanks in advance.

I have found two key things:

  1. Disable Navigation on the Scrollbar.
  2. Disable the Checkbox for the scrollbar itself (Vertical/Horizontal) on the Scroll Rect

2 has some weird consequences tho…

Thanks for your reply.
This is the hierarchy of the ui objects.
The video list object is the canvas where the VRC_UIShape is placed. (Currently I removed the UI shape component while it still scrolls with keyboard input)

I’m not sure if you mean setting the scrollbar navigation to none, it seems setting it to none does not work. Somehow the keyboard scrolling seems to be the default behavior of the Scroll Rect. :sweat_smile:

If you can figure out a way, that’d be great. I was lookin’ around for ways to do it a while back. Some stuff I’ve tried to no avail:

  • Set Navigation to None (Only moves with WASD while mousing over.)
  • Unchecked Horizontal and Vertical on scroll rect. (No scrolling possible)
  • Delete ViewPort from the Scroll Rect (no effect)
  • Delete Vertical/Horizontal Scrollbar from Scroll Rect (Disables scrolling for everything but movement keys)
  • Set Navigation to Explicit with no events defined (Enables scrolling even when not moused over)
  • Set Navigation to Explicit with my scrollbar in all events ( Same as Navigation: None)
  • Went to Project Settings -> Input -> Axes and changed Horizontal/Vertical input settings (No change)

There might be some workaround that’s a combination of the above but I kinda just gave up on it.

I also tried changing the layer of just the Scroll Rect to be UiMenu in hopes that you could only scroll it while having the quick menu open, but no effect. I think layer has to be set on the Canvas itself.

Thanks eremite, it seems that this behavior is not one that comes from the original unity UI ScrollRect component (correct me if I am wrong), so it’s possible that we have no control over it.
Disabling the ScrollRect and instead setting the normalized position value with the scroll bar can avoid the keyboard scrolling but it has no fancy dragging effects like inertial effect unfortunately.
Some triggers or udon scripts may be used to disable the scrolling if user is far way from the canvas or in some sense “not supposed to control the scrollrect” but still it’s not a elegant way.(for some usage scenario it should be fine) :laughing:
Hope there are some better ways.

It’s well impossible to do purely from the Unity options, but there is a way to do this if you use scripts. I just achieved it.

Create 2 Udon scripts, one on the textcontent view (the one with scrollrect) and on the scrollbar.

Filter for any keys being pressed (W A S D , Left, Right, Up, Down), and if found, disable the scrollrect and stop it’s motion. On the scrollbar, on onValueChanged, set it to enable the scrollrect.

Effect: Any W A S D keys do nothing, click on the scrollbar to move it and it works. I’ll probably add a prefab to my GitHub later

(Note, as a result of the way it’s done, sometimes a pixel or 2 of movement is made, but it’s near unnoticeable)

Thank you indominablerexx, I think your design will well meet my need, I will try it out as soon as videoplayers are avaliable for SDK3. :smile:

If you are clever enough, you could probably find a way to compensate for that 2 pixel of movement

I guess caching a position of the last update would solve the problem?

Something like that. I haven’t verified if it’s possible to change the value and have it actually move though. Haven’t got a good testing setup going, and I probably won’t bother too much since it’s working well already.

You can even enable dragging on the text content by placing a script on the canvas , watching for mouse events, blocking out the keys, and such. Almost 100% identical behavior to the original, except no W A S D messing it up

1 Like