--[BUGFIX] query both x and y offset in mouseScrollEvent for an active scroll.#1040
Conversation
| // shift+scroll is forced into x direction on mac, seemingly at OS level, so | ||
| // use both x and y offsets. | ||
| float scrollModVal = event.offset().y() + event.offset().x(); | ||
| if (!(scrollModVal)) { |
There was a problem hiding this comment.
As we discussed on Slack -- I'd rather want to see this fixed / worked around / configured at some upper level than in the application code...
There was a problem hiding this comment.
The question remains, though, should we intercept it at a lower level? I would imagine folks might want to see/use this behavior in other UI applications (if any existed -shrug-)
There was a problem hiding this comment.
I'm not a chronic mac user, and I don't know if we would ever implement something in sim/viewer that would take advantage of horizontal scrolling explicitly, so I figured this was the route of least commitment :)
There was a problem hiding this comment.
intercept it at a lower level?
Yeah, depends. If I would patch this in Magnum, I would add some window flag to the Application to toggle this behavior (I'm neither a fan of Apple forcing this to everyone nor a library reverting that behavior unconditionally).
I would also need to check how this behaves in SDL, if it's already accounted for in some way or not.
| void Viewer::mouseScrollEvent(MouseScrollEvent& event) { | ||
| if (!event.offset().y()) { | ||
| // shift+scroll is forced into x direction on mac, seemingly at OS level, so | ||
| // use both x and y offsets. |
There was a problem hiding this comment.
To limit this weird workaround a bit, I'd suggest to wrap it in #ifdef CORRADE_TARGET_APPLE, at least.
| if (!event.offset().y()) { | ||
| // shift+scroll is forced into x direction on mac, seemingly at OS level, so | ||
| // use both x and y offsets. | ||
| float scrollModVal = event.offset().y() + event.offset().x(); |
There was a problem hiding this comment.
| float scrollModVal = event.offset().y() + event.offset().x(); | |
| float scrollModVal = event.offset().max(); |
shorter / less error-prone, maybe? On touchpads you can have both directions and so the two could cancel each other out. I think the max() could work reasonably well there too.
There was a problem hiding this comment.
is it an abs max? Can be + or -
There was a problem hiding this comment.
Also, the x displacement is roughly 10x as big as the y, which was why i added them, but as you say, max would work too, if it is a magnitude max.
There was a problem hiding this comment.
Ah, no it's not, good point. blargh, that's also wrongMn::Math::abs(event.offset()).max() then :)
Mn::Math::sign(event.offset())*Mn::Math::abs(event.offset()).max() 😅 😅
There was a problem hiding this comment.
How about this :
float scrollModVal = abs(event.offset().y()) > abs(event.offset().x())
? event.offset().y()
: event.offset().x();
There was a problem hiding this comment.
This way then any mouse scrolling on 1d or 2d mice, platform independent, will accomplish something expected, maybe?
87db94d to
dce16a2
Compare
Motivation and Context
This PR fixes a bug with how viewer processes mouseScrollEvent offsets on a mac by looking at both x and y offsets if a mouseScrollEvent is processed. If shift is pressed, the scroll is defaulted to be horizontal on a mac, whereas previously in viewer we only examined the y offset to determine if a valid scroll has occurred, and in what direction.
How Has This Been Tested
C++ and python
Types of changes
Checklist