From a01cade7823ef2f05442bef19f1b611d258d0f4a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 24 Jan 2007 12:21:29 +0000 Subject: [PATCH] Added setHandled/getHandled to osgGA::GUIEventAdapter --- include/osgGA/GUIEventAdapter | 9 ++++++++- src/osgGA/GUIEventAdapter.cpp | 2 ++ src/osgGA/GUIEventHandler.cpp | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/osgGA/GUIEventAdapter b/include/osgGA/GUIEventAdapter index 539bcade4..2147d9f7f 100644 --- a/include/osgGA/GUIEventAdapter +++ b/include/osgGA/GUIEventAdapter @@ -257,6 +257,12 @@ public: GUIEventAdapter(); GUIEventAdapter(const GUIEventAdapter& rhs); + + /** Set whether this event has been handled by an event handler or not.*/ + void setHandled(bool handled) { _handled = handled; } + + /** Get whether this event has been handled by an event handler or not.*/ + bool getHandled() const { return _handled; } /** Get the Type of the GUI GUIEventAdapter.*/ void setEventType(EventType Type) { _eventType = Type; } @@ -393,7 +399,8 @@ public: /** Force users to create on heap, so that multiple referencing is safe.*/ virtual ~GUIEventAdapter(); - + + bool _handled; EventType _eventType; double _time; diff --git a/src/osgGA/GUIEventAdapter.cpp b/src/osgGA/GUIEventAdapter.cpp index 5ad47e894..5095b4003 100644 --- a/src/osgGA/GUIEventAdapter.cpp +++ b/src/osgGA/GUIEventAdapter.cpp @@ -16,6 +16,7 @@ using namespace osgGA; GUIEventAdapter::GUIEventAdapter(): + _handled(false), _eventType(NONE), _time(0.0), _windowX(0), @@ -42,6 +43,7 @@ GUIEventAdapter::GUIEventAdapter(): GUIEventAdapter::GUIEventAdapter(const GUIEventAdapter& rhs): osg::Referenced(), + _handled(rhs._handled), _eventType(rhs._eventType), _time(rhs._time), _windowX(rhs._windowX), diff --git a/src/osgGA/GUIEventHandler.cpp b/src/osgGA/GUIEventHandler.cpp index ba5f0b855..5e12d7757 100644 --- a/src/osgGA/GUIEventHandler.cpp +++ b/src/osgGA/GUIEventHandler.cpp @@ -28,11 +28,11 @@ void GUIEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv) { if (handle(*(*itr), *(ev->getActionAdapter()), node, nv)) { - return; + (*itr)->setHandled(true); } } } - traverse(node,nv); + if (node->getNumChildrenRequiringEventTraversal()>0) traverse(node,nv); } void GUIEventHandler::event(osg::NodeVisitor* nv, osg::Drawable* drawable)