Fix T47393: mouse wheel scroll no longer zooms with mighty mouse on OS X.

Hopefully this is the last fix, using the method explained here:
https://forums.developer.apple.com/thread/31536
This commit is contained in:
Brecht Van Lommel 2016-02-13 13:13:59 +01:00
parent 6a593aba44
commit 88770bed7c
Notes: blender-bot 2024-01-16 18:05:25 +01:00
Referenced by issue #47393, Default Mouse Wheel Zoom broken (changed from zoom to rotation) - OSX only
2 changed files with 14 additions and 8 deletions

View File

@ -299,6 +299,8 @@ protected:
/** Temporarily ignore momentum scroll events */
bool m_ignoreMomentumScroll;
/** Is the scroll wheel event generated by a multitouch trackpad or mouse? */
bool m_multiTouchScroll;
};
#endif // __GHOST_SYSTEMCOCOA_H__

View File

@ -375,6 +375,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
m_ignoreWindowSizedMessages = false;
m_ignoreMomentumScroll = false;
m_multiTouchScroll = false;
}
GHOST_SystemCocoa::~GHOST_SystemCocoa()
@ -1392,31 +1393,34 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
{
NSEventPhase momentumPhase = NSEventPhaseNone;
NSEventPhase phase = NSEventPhaseNone;
bool hasMultiTouch = false;
if ([event respondsToSelector:@selector(momentumPhase)])
momentumPhase = [event momentumPhase];
if ([event respondsToSelector:@selector(phase)])
phase = [event phase];
if ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)])
hasMultiTouch = [event hasPreciseScrollingDeltas] && [event subtype] != NSMouseEventSubtype;
/* when pressing a key while momentum scrolling continues after
* lifting fingers off the trackpad, the action can unexpectedly
* change from e.g. scrolling to zooming. this works around the
* issue by ignoring momentum scroll after a key press */
if (momentumPhase)
{
if (momentumPhase) {
if (m_ignoreMomentumScroll)
break;
}
else
{
else {
m_ignoreMomentumScroll = false;
}
/* we assume phases are only set for gestures from trackpad or magic
* mouse events. note that using tablet at the same time may not work
* since this is a static variable */
if (phase == NSEventPhaseBegan)
m_multiTouchScroll = true;
else if (phase == NSEventPhaseEnded)
m_multiTouchScroll = false;
/* standard scrollwheel case, if no swiping happened, and no momentum (kinetic scroll) works */
if (!hasMultiTouch && momentumPhase == NSEventPhaseNone) {
if (!m_multiTouchScroll && momentumPhase == NSEventPhaseNone) {
GHOST_TInt32 delta;
double deltaF = [event deltaY];