bool MouseHandler::handle( const osgGA::GUIEventAdapter &gea, osgGA::GUIActionAdapter& /*gaa*/, osg::Object* /*obj*/, osg::NodeVisitor* /*nv*/ ) { osgGA::GUIEventAdapter::EventType ev = gea.getEventType(); MouseAction ma = _isMouseEvent(ev); if (ma) { // If we're scrolling, we need to inform the WindowManager of that. _wm->setScrollingMotion(gea.getScrollingMotion()); // osgWidget assumes origin is bottom left of window so make sure mouse coordinate are increaseing y upwards and are scaled to window size. float x = (gea.getX() - gea.getXmin()) / (gea.getXmax() - gea.getXmin()) * static_cast<float>(gea.getWindowWidth()); float y = (gea.getY() - gea.getYmin()) / (gea.getYmax() - gea.getYmin()) * static_cast<float>(gea.getWindowHeight()); if (gea.getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS) y = static_cast<float>(gea.getWindowHeight()) - y; // OSG_NOTICE<<"MouseHandler(x="<<x<<", y="<<y<<")"<<std::endl; return (this->*ma)(x, y, gea.getButton()); } return false; }
bool MouseHandler::handle( const osgGA::GUIEventAdapter& gea, osgGA::GUIActionAdapter& gaa, osg::Object* obj, osg::NodeVisitor* nv ) { osgGA::GUIEventAdapter::EventType ev = gea.getEventType(); MouseAction ma = _isMouseEvent(ev); if(ma) { // If we're scrolling, we need to inform the WindowManager of that. _wm->setScrollingMotion(gea.getScrollingMotion()); return (this->*ma)(gea.getX(), gea.getY(), gea.getButton()); } return false; }