Show
Ignore:
Timestamp:
03/11/09 15:18:30 (5 years ago)
Author:
robert
Message:

Added View::removeEventHandler(..) method and added check into addEventHandler() to prevent handlers being added twice.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgViewer/View.cpp

    r9892 r9909  
    358358void View::addEventHandler(osgGA::GUIEventHandler* eventHandler) 
    359359{  
    360     _eventHandlers.push_back(eventHandler); 
     360    EventHandlers::iterator itr = std::find(_eventHandlers.begin(), _eventHandlers.end(), eventHandler); 
     361    if (itr == _eventHandlers.end()) 
     362    { 
     363        _eventHandlers.push_back(eventHandler); 
     364    } 
     365} 
     366 
     367void View::removeEventHandler(osgGA::GUIEventHandler* eventHandler) 
     368{ 
     369    EventHandlers::iterator itr = std::find(_eventHandlers.begin(), _eventHandlers.end(), eventHandler); 
     370    if (itr != _eventHandlers.end()) 
     371    { 
     372        _eventHandlers.erase(itr); 
     373    } 
    361374} 
    362375