1
0
Fork 0

Restore PUI scrolling event behaviour

Fixes zooming in the map, for example.
This commit is contained in:
James Turner 2017-11-15 16:35:07 +00:00
parent 15fbf1f9cd
commit 723e631f87

View file

@ -149,11 +149,15 @@ public:
case osgGA::GUIEventAdapter::SCROLL: case osgGA::GUIEventAdapter::SCROLL:
{ {
const int button = (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP) ? const int button = buttonForScrollEvent(ea);
PU_SCROLL_UP_BUTTON : PU_SCROLL_DOWN_BUTTON; if (button != PU_NOBUTTON) {
// sent both down and up events for a single scroll, for
// compatability
bool handled = puMouse(button, PU_DOWN, scaledX, scaledY); bool handled = puMouse(button, PU_DOWN, scaledX, scaledY);
puMouse(button, PU_UP, scaledX, scaledY);
return handled; return handled;
} }
}
case (osgGA::GUIEventAdapter::RESIZE): case (osgGA::GUIEventAdapter::RESIZE):
@ -180,6 +184,36 @@ private:
return 0; return 0;
} }
int buttonForScrollEvent(const osgGA::GUIEventAdapter &ea) const
{
if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_2D) {
int button = PU_NOBUTTON;
if (ea.getScrollingDeltaY() > 0)
button = PU_SCROLL_UP_BUTTON;
else if (ea.getScrollingDeltaY() < 0)
button = PU_SCROLL_DOWN_BUTTON;
#if defined(SG_MAC)
// bug https://code.google.com/p/flightgear-bugs/issues/detail?id=1286
// Mac (Cocoa) interprets shift+wheel as horizontal scroll
if (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_SHIFT) {
if (ea.getScrollingDeltaX() > 0) {
button = PU_SCROLL_UP_BUTTON;
} else if (ea.getScrollingDeltaX() < 0) {
button = PU_SCROLL_DOWN_BUTTON;
}
}
#endif
return button;
} else if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP) {
return PU_SCROLL_UP_BUTTON;
} else {
return PU_SCROLL_DOWN_BUTTON;
}
return PU_NOBUTTON;
}
PUICamera* _puiCamera; PUICamera* _puiCamera;
}; };