Ok. Here I go:
I’ll discuss the current implementation, then I’ll propose an ideal implementation (but with disregard to backwards compatibility), then discuss the greater issue of maintaining backwards compatibility.
So, currently, when you scroll with the trackpad, the system waits for you to reach a movement threshold with your fingers, then sends a “clumped up” event sequence (pressed = true
, then, immediately, released = true
).
In the ideal implementation, when the user would scroll, a MOUSE_WHEEL_UP/DOWN
event would get sent every time the user moved the fingers just a bit with screen_dx
and screen_dy
set to the amount of pixels scrolled and value
(or another property) would indicate wether the scroll is a genuine user scroll (1
) or inertial scrolling generated by the system (0
). Conventional mouse wheel events would be differentiated by a value
of 2
maybe and would have screen_dy
set to a fixed value configurable from game.project
.
EDIT: It would also be useful to track entire scroll sequences, so, when possible, pressed
would be sent when the user begins the scrolling action, repeated
throughout and released
when the inertial scrolling finally ended.
EDIT: It’s important to know when the user scrolls and when inertial scrolling scrolls because inertial scrolling should be cancelable (or well, ignorable) in certain scenarios (like when implementing overscrolling bounce-back in a scroll view)
Of course, this would break compatibility with the old behavior of MOUSE_WHEEL_UP/DOWN
, which is why I propose to apply the beforementioned behavior to a new MOUSE_SCROLL
event and keep MOUSE_WHEEL_UP/DOWN
as it is. My only concern with this approach is that it devs (especially devs who don’t use a smooth scrolling trackpad) might not hear about MOUSE_SCROLL
and just use MOUSE_WHEEL_UP/DOWN
, but I guess that could be solved through documentation.
I’m not sure if this is really the best way to design this, but at least I hope this outlined what kind of information would be necessary to implement a really great scroll view UI component.
Also, I’m sure not all platforms provide all this info (the web doesn’t provide scroll sequence information and inertial scrolling information, as far as I know, for example), but it’s best to offer all the info you have to the developer in a form that allows for progressive enhancement of UX on platforms that do support all the features.