From e295d991a6b1221e35e80fe996b8a6bf01089dbb Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Fri, 9 Feb 2018 18:26:07 +0100 Subject: [PATCH] Canvas/PUI: Fix interfering drag --- src/Viewer/PUICamera.cxx | 41 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Viewer/PUICamera.cxx b/src/Viewer/PUICamera.cxx index 420270a10..eea14b77d 100644 --- a/src/Viewer/PUICamera.cxx +++ b/src/Viewer/PUICamera.cxx @@ -153,20 +153,12 @@ public: switch(ea.getEventType()) { - case(osgGA::GUIEventAdapter::MOVE): case(osgGA::GUIEventAdapter::DRAG): - { - FGMouseInput* mouseSubsystem = globals->get_subsystem()->get_subsystem(); - if (mouseSubsystem && - mouseSubsystem->isRightDragToLookEnabled() && - _mouse0RightButtonNode->getBoolValue()) - { + if (!_is_dragging) return false; - } - - bool handled = puMouse(scaledX, scaledY); - return handled; - } + // No break + case(osgGA::GUIEventAdapter::MOVE): + return puMouse(scaledX, scaledY); case(osgGA::GUIEventAdapter::PUSH): case(osgGA::GUIEventAdapter::RELEASE): @@ -179,8 +171,17 @@ public: return false; } - bool upOrDown = (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE); - bool handled = puMouse(osgButtonToPUI(ea), upOrDown, scaledX, scaledY); + bool mouse_up = (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE); + bool handled = puMouse(osgButtonToPUI(ea), mouse_up, scaledX, scaledY); + if (!mouse_up && handled) + { + _is_dragging = true; + } + // Release drag if no more buttons are pressed + else if (mouse_up && !ea.getButtonMask()) + { + _is_dragging = false; + } return handled; } @@ -200,12 +201,12 @@ public: // sent both down and up events for a single scroll, for // compatability bool handled = puMouse(button, PU_DOWN, scaledX, scaledY); - puMouse(button, PU_UP, scaledX, scaledY); + handled |= puMouse(button, PU_UP, scaledX, scaledY); return handled; } + return false; } - - + case (osgGA::GUIEventAdapter::RESIZE): _puiCamera->resizeUi(ea.getWindowWidth(), ea.getWindowHeight()); break; @@ -259,8 +260,10 @@ private: return PU_NOBUTTON; } - - PUICamera* _puiCamera; + + PUICamera* _puiCamera = nullptr; + bool _is_dragging = false; + SGPropertyNode_ptr _mouse0RightButtonNode; };