Hi Creators,
We’re releasing an overhaul of how the engine handles scroll and trackpad inputs. For the most part this is a strict improvement, enabling the trackpad behavior people expect and fixing some nasty bugs, but it has some small backwards compatibility considerations.
In this post we’ll go over the current state of things, the new changes, and what potential problems to double check for in your scripts.
TL;DR:
The way the engine gets scroll inputs from trackpad / MagicMouse is changing and you may need to update your code to maintain your intended zoom / scroll rates.
-
The delta value passed in
InputObject.Position.Z
forMouseWheel
events is changing.- Previously: The delta was always -1 or 1, except on Mac Client, where it was never larger than one but was often fractional.
- Upcoming: The delta value is for the most part directly proportional to what the underlying system scroll event specified, and may be any floating point number on any platform.
-
We’re not expecting this to have a large impact because mobile remains unchanged and we included backwards compatibility affordances for most APIs.
-
Update checks like
wheelInputObject.Position.Z == 1
to avoid breakage. -
APIs other than
MouseWheel
input objects remain unchanged. -
This will be rolled out in-experience by the end of March.
Current state of scrolling behavior
If you’ve ever dealt with event handling code much on Roblox, you’ve probably run into some confounding behavior related to scrolling, especially if you’ve tried to write code that handles multiple platforms. Here’s a brief rundown of just some of the current weirdness.
-
Mac Client and Mac Studio playtesting have completely different camera behavior.
-
Zooming out is faster than zooming in with Mac Studio but not with Windows Studio.
-
Windows trackpads do not scroll smoothly, they always scroll in steps like a mouse wheel.
-
ScrollingFrames scroll at hyperspeed when using a Mac trackpad.
-
On Mac Client you can horizontally pan a ScrollingFrame with MagicMouse but not trackpad.
-
On Windows, wheel delta = 0.5 for
UserInputService.PointerAction
but 1 for InputObjects. -
Shift + Scroll to pan a ScrollingFrame works in Mac Client and Windows Studio but not Mac Studio.
How did we end up here?
Roblox has evolved to support more and more platforms and input devices over the years. Each round of support was well written on its own, but had a few rough edges. Unfortunately, not only do those rough edges add up over time, they compound, resulting in ever weirder behaviors.
Now, we’re thoroughly shaking all the accumulated nonsense out of the system.
Upcoming state of scrolling behavior
Our philosophy is to peel back all of the accumulated special cases in the platform specific trackpad / mouse code. Once we’ve done this, the clients can pass the native scroll behavior players expect from their systems directly to the engine, with just a few pieces of targeted backwards compatibility where required.
Following that philosophy, here’s what’s changing:
-
Windows Client / Studio, Mac Studio, Android, and Playstation no longer restrict scroll deltas.
-
Some input devices on those platforms will now pass scroll deltas other than -1 / 1.
-
Mac Client no longer limits the scroll delta to 1; flicks may be larger than 1.
-
This naturally supports smooth vertical trackpad scrolling on all platforms.
-
While playtesting, Mac Studio behavior now matches Mac Client behavior.
-
Inertia scrolling is enabled for ScrollingFrames on Mac.
-
The horizontal panning direction for ScrollingFrames was inverted, this has been fixed.
To avoid breaking existing code, we’ve also done the following:
-
Mouse.WheelForward
andGuiObject.MouseWheelForward
have been given reasonable behavior with all input devices. They offer a built in solution for scrolling in steps / pages. -
The camera scripts have used
UserInputService.PointerAction
for input since 2019. This event will continue to fire with comparable values to support forked camera scripts. -
We enabled inertia (continued movement after lifting your finger) for ScrollingFrames on platforms which support that. To avoid giving in-experience cameras on Mac unexpected inertia, public APIs like
MouseWheel / PointerAction
exclude events resulting from inertia on Mac.
Natural extensions which haven’t been implemented yet:
-
Horizontal trackpad inputs on platforms other than Mac.
-
Pinch to zoom in Studio (use I/O when playtesting on Mac if you have no mouse wheel)
Timeline
-
We’re adding a “Scroll Event Overhaul” beta feature in this week’s Studio release to test your code against the new behavior.
-
We’re going to attempt to enable the changes in mid March, and will keep the thread updated with what we’re doing. This is a complex change covering every platform so some platforms may have it enabled while others don’t as we work on rolling it out.
What’s needed from you
Check your code for two problematic UserInputType.MouseWheel
patterns:
-
Code which checks
inputObject.Position.Z > 0
but does not use the delta value will scroll excessively fast with a trackpad because it overestimates the intended delta. -
Code which checks
inputObject.Position.Z == 1
will no longer scroll at all with trackpad because the scroll value won’t be exactly equal to 1.
If you find one of these patterns, here’s how to avoid breakage when we release the changes:
-
If you want to scroll/zoom by a distance related to the input you should use the delta value in your math something like
zoomAmount = rate * inputObject.Position.Z
. -
If you want to scroll in discrete pages / steps, use
mouse.WheelForwards
,someGuiObject.MouseWheelForwards
orUIPageLayout
which we’re mapping to a reasonable cross-device behavior out of the box.
You can test your code in Studio using the Scroll Event Overhaul beta feature once we make that available, or on Mac Client since Mac Client already sends smaller deltas when using trackpad / MagicMouse. Code which currently works on Mac Client should not require any changes.
Things to pay particular attention to:
-
Studio plugin UIs with custom scrolling behavior not using ScrollingFrame.
-
FPS experiences where you scroll to switch weapons.
-
Old camera code forked before 2019 (when
PointerAction
was introduced). -
The zoom sensitivity of custom camera code using
WheelEvent
.
Let us know if you have any questions or concerns, thanks!