From: timoore Date: Mon, 20 Aug 2007 21:38:25 +0000 (+0000) Subject: Handle scroll wheel events in osgViewer version X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=aa2858b5bd65c108409ea8807684e97912155541;p=flightgear.git Handle scroll wheel events in osgViewer version --- diff --git a/src/Main/FGManipulator.cxx b/src/Main/FGManipulator.cxx index 416ecf529..058641981 100644 --- a/src/Main/FGManipulator.cxx +++ b/src/Main/FGManipulator.cxx @@ -6,6 +6,10 @@ #include #include "FGManipulator.hxx" +#if !defined(X_DISPLAY_MISSING) +#define X_DOUBLE_SCROLL_BUG 1 +#endif + // The manipulator is responsible for updating a Viewer's camera. It's // event handling method is also a convenient place to run the the FG // idle and draw handlers. @@ -13,7 +17,8 @@ FGManipulator::FGManipulator() : idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0), mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0), - osgModifiers(0), resizable(true), mouseWarped(false) + osgModifiers(0), resizable(true), mouseWarped(false), + scrollButtonPressed(false) { using namespace osgGA; @@ -166,6 +171,25 @@ bool FGManipulator::handle(const osgGA::GUIEventAdapter& ea, == osgGA::GUIEventAdapter::RELEASE), x, y, mainWindow, &ea); return true; } + case osgGA::GUIEventAdapter::SCROLL: + { + bool mainWindow = eventToViewport(ea, us, x, y); +#ifdef X_DOUBLE_SCROLL_BUG + scrollButtonPressed = !scrollButtonPressed; + if (!scrollButtonPressed) // Drop the button release event + return true; +#endif + int button; + if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP) + button = 3; + else + button = 4; + if (mouseClickHandler) { + (*mouseClickHandler)(button, 0, x, y, mainWindow, &ea); + (*mouseClickHandler)(button, 1, x, y, mainWindow, &ea); + } + return true; + } case osgGA::GUIEventAdapter::MOVE: case osgGA::GUIEventAdapter::DRAG: // If we warped the mouse, then disregard all pointer motion diff --git a/src/Main/FGManipulator.hxx b/src/Main/FGManipulator.hxx index 5412ce6f3..4ad190d19 100644 --- a/src/Main/FGManipulator.hxx +++ b/src/Main/FGManipulator.hxx @@ -137,5 +137,7 @@ protected: void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers); bool resizable; bool mouseWarped; + // workaround for osgViewer double scroll events + bool scrollButtonPressed; }; #endif