From c0c5e73ff9d204a790775fcb6fc6fe36fd9b1b77 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 27 Jul 2006 12:32:40 +0000 Subject: [PATCH] From Michael Polak, double click fixes/additions --- include/osgGA/EventQueue | 3 +++ src/osgGA/EventQueue.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/osgGA/EventQueue b/include/osgGA/EventQueue index b92fcbac8..27ece7762 100644 --- a/include/osgGA/EventQueue +++ b/include/osgGA/EventQueue @@ -74,6 +74,9 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced /** method for adapting mouse button pressed events, placing this event on the back of the event queue.*/ void mouseButtonPress(float x, float y, unsigned int button); + + /** method for adapting mouse button pressed events, placing this event on the back of the event queue.*/ + void mouseDoubleButtonPress(float x, float y, unsigned int button); /** method for adapting mouse button release events, placing this event on the back of the event queue.*/ void mouseButtonRelease(float x, float y, unsigned int button); diff --git a/src/osgGA/EventQueue.cpp b/src/osgGA/EventQueue.cpp index 267914b08..586c541c2 100644 --- a/src/osgGA/EventQueue.cpp +++ b/src/osgGA/EventQueue.cpp @@ -179,6 +179,43 @@ void EventQueue::mouseButtonPress(float x, float y, unsigned int button) addEvent(event); } +void EventQueue::mouseDoubleButtonPress(float x, float y, unsigned int button) +{ + _accumulateEventState->setX(x); + _accumulateEventState->setY(y); + + switch(button) + { + case(1): + _accumulateEventState->setButtonMask(GUIEventAdapter::LEFT_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); + break; + case(2): + _accumulateEventState->setButtonMask(GUIEventAdapter::MIDDLE_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); + break; + case(3): + _accumulateEventState->setButtonMask(GUIEventAdapter::RIGHT_MOUSE_BUTTON | _accumulateEventState->getButtonMask()); + break; + } + + GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); + event->setEventType(GUIEventAdapter::DOUBLECLICK); + + switch(button) + { + case(1): + event->setButton(GUIEventAdapter::LEFT_MOUSE_BUTTON); + break; + case(2): + event->setButton(GUIEventAdapter::MIDDLE_MOUSE_BUTTON); + break; + case(3): + event->setButton(GUIEventAdapter::RIGHT_MOUSE_BUTTON); + break; + } + + addEvent(event); +} + void EventQueue::mouseButtonRelease(float x, float y, unsigned int button) { _accumulateEventState->setX(x);