Canvas/PUI: Fix interfering drag
This commit is contained in:
parent
c2e7842110
commit
e295d991a6
1 changed files with 22 additions and 19 deletions
|
@ -153,20 +153,12 @@ public:
|
||||||
|
|
||||||
switch(ea.getEventType())
|
switch(ea.getEventType())
|
||||||
{
|
{
|
||||||
case(osgGA::GUIEventAdapter::MOVE):
|
|
||||||
case(osgGA::GUIEventAdapter::DRAG):
|
case(osgGA::GUIEventAdapter::DRAG):
|
||||||
{
|
if (!_is_dragging)
|
||||||
FGMouseInput* mouseSubsystem = globals->get_subsystem<FGInput>()->get_subsystem<FGMouseInput>();
|
|
||||||
if (mouseSubsystem &&
|
|
||||||
mouseSubsystem->isRightDragToLookEnabled() &&
|
|
||||||
_mouse0RightButtonNode->getBoolValue())
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
// No break
|
||||||
|
case(osgGA::GUIEventAdapter::MOVE):
|
||||||
bool handled = puMouse(scaledX, scaledY);
|
return puMouse(scaledX, scaledY);
|
||||||
return handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
case(osgGA::GUIEventAdapter::PUSH):
|
case(osgGA::GUIEventAdapter::PUSH):
|
||||||
case(osgGA::GUIEventAdapter::RELEASE):
|
case(osgGA::GUIEventAdapter::RELEASE):
|
||||||
|
@ -179,8 +171,17 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool upOrDown = (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE);
|
bool mouse_up = (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE);
|
||||||
bool handled = puMouse(osgButtonToPUI(ea), upOrDown, scaledX, scaledY);
|
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;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,12 +201,12 @@ public:
|
||||||
// sent both down and up events for a single scroll, for
|
// sent both down and up events for a single scroll, for
|
||||||
// compatability
|
// compatability
|
||||||
bool handled = puMouse(button, PU_DOWN, scaledX, scaledY);
|
bool handled = puMouse(button, PU_DOWN, scaledX, scaledY);
|
||||||
puMouse(button, PU_UP, scaledX, scaledY);
|
handled |= puMouse(button, PU_UP, scaledX, scaledY);
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case (osgGA::GUIEventAdapter::RESIZE):
|
case (osgGA::GUIEventAdapter::RESIZE):
|
||||||
_puiCamera->resizeUi(ea.getWindowWidth(), ea.getWindowHeight());
|
_puiCamera->resizeUi(ea.getWindowWidth(), ea.getWindowHeight());
|
||||||
break;
|
break;
|
||||||
|
@ -259,8 +260,10 @@ private:
|
||||||
|
|
||||||
return PU_NOBUTTON;
|
return PU_NOBUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
PUICamera* _puiCamera;
|
PUICamera* _puiCamera = nullptr;
|
||||||
|
bool _is_dragging = false;
|
||||||
|
|
||||||
SGPropertyNode_ptr _mouse0RightButtonNode;
|
SGPropertyNode_ptr _mouse0RightButtonNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue