From Marco Jez, added setEventHandled() and getEventHandled() to osgGA::EventVisitor.

This commit is contained in:
Robert Osfield 2005-07-27 09:37:26 +00:00
parent b9a74c87e1
commit 72a59527f5
4 changed files with 28 additions and 11 deletions

View File

@ -63,6 +63,10 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
void addEvent(GUIEventAdapter* event);
void removeEvent(GUIEventAdapter* event);
bool getEventHandled() const { return _handled; }
void setEventHandled(bool handled) { _handled = handled; }
virtual void reset();
@ -134,6 +138,7 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
osgGA::GUIActionAdapter* _actionAdapter;
EventList _events;
bool _handled;
};

View File

@ -17,7 +17,9 @@
using namespace osg;
using namespace osgGA;
EventVisitor::EventVisitor():NodeVisitor(UPDATE_VISITOR,TRAVERSE_ALL_CHILDREN)
EventVisitor::EventVisitor()
: NodeVisitor(UPDATE_VISITOR,TRAVERSE_ALL_CHILDREN),
_handled(false)
{
}
@ -41,4 +43,5 @@ void EventVisitor::removeEvent(GUIEventAdapter* event)
void EventVisitor::reset()
{
_events.clear();
_handled = false;
}

View File

@ -26,7 +26,11 @@ void GUIEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
itr != ev->getEventList().end();
++itr)
{
handle(*(*itr), *(ev->getActionAdapter()), node, nv);
if (handle(*(*itr), *(ev->getActionAdapter()), node, nv))
{
ev->setEventHandled(true);
return;
}
}
}
traverse(node,nv);

View File

@ -81,11 +81,11 @@ public:
_piv.setTraversalMask(traversalMask);
}
// Aug 2003 added to pass the nodemaskOverride to the PickIntersectVisitor
// Aug 2003 added to pass the nodemaskOverride to the PickIntersectVisitor
// may be used make the visitor override the nodemask to visit invisible actions
inline void setNodeMaskOverride(osg::Node::NodeMask mask) {
_piv.setNodeMaskOverride(mask);
_nodeMaskOverride = mask; }
_piv.setNodeMaskOverride(mask);
_nodeMaskOverride = mask; }
virtual void apply(osg::Projection& pr)
@ -698,17 +698,21 @@ void Viewer::update()
++event_itr)
{
bool handled = false;
for(EventHandlerList::iterator handler_itr=_eventHandlerList.begin();
handler_itr!=_eventHandlerList.end() && !handled;
++handler_itr)
{
handled = (*handler_itr)->handle(*(*event_itr),*this,0,0);
}
if (_eventVisitor.valid())
{
_eventVisitor->reset();
_eventVisitor->addEvent(event_itr->get());
getTopMostSceneData()->accept(*_eventVisitor);
if (_eventVisitor->getEventHandled())
handled = true;
}
for(EventHandlerList::iterator handler_itr=_eventHandlerList.begin();
handler_itr!=_eventHandlerList.end() && !handled;
++handler_itr)
{
handled = (*handler_itr)->handle(*(*event_itr),*this,0,0);
}
}
@ -1014,3 +1018,4 @@ void Viewer::getUsage(osg::ApplicationUsage& usage) const
(*itr)->getUsage(usage);
}
}