Added View::removeEventHandler(..) method and added check into addEventHandler() to prevent handlers being added twice.
This commit is contained in:
parent
d808149e05
commit
998cfec137
@ -117,6 +117,9 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
/** Add an EventHandler that adds handling of events to the View.*/
|
||||
void addEventHandler(osgGA::GUIEventHandler* eventHandler);
|
||||
|
||||
/** Remove an EventHandler from View.*/
|
||||
void removeEventHandler(osgGA::GUIEventHandler* eventHandler);
|
||||
|
||||
/** Get the View's list of EventHandlers.*/
|
||||
EventHandlers& getEventHandlers() { return _eventHandlers; }
|
||||
|
||||
|
@ -356,9 +356,22 @@ void View::home()
|
||||
|
||||
|
||||
void View::addEventHandler(osgGA::GUIEventHandler* eventHandler)
|
||||
{
|
||||
EventHandlers::iterator itr = std::find(_eventHandlers.begin(), _eventHandlers.end(), eventHandler);
|
||||
if (itr == _eventHandlers.end())
|
||||
{
|
||||
_eventHandlers.push_back(eventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
void View::removeEventHandler(osgGA::GUIEventHandler* eventHandler)
|
||||
{
|
||||
EventHandlers::iterator itr = std::find(_eventHandlers.begin(), _eventHandlers.end(), eventHandler);
|
||||
if (itr != _eventHandlers.end())
|
||||
{
|
||||
_eventHandlers.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
void View::setCoordinateSystemNodePath(const osg::NodePath& nodePath)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user