|
想在拖拽器上获取到鼠标滚轮的消息,但是通过ea.getEventType()无法获取到SCROLL类型。看了几篇帖子,发现可以从漫游器中抓到该消息,但是不知道是哪里的设置需要打开才能收到。
请哪位大侠出手相助一下,谢谢~~
具体代码如下:
1、这里是OrbitManipulator漫游器能抓到滚轮事件,处理后返回true。
- /// Handles GUIEventAdapter::SCROLL event.
- bool OrbitManipulator::handleMouseWheel( const GUIEventAdapter& ea, GUIActionAdapter& us )
复制代码
2、这里是GUIEventHandler中的处理代码,是否和_ignoreHandledEventsMask这个变量有关?
-
- inline bool handleWithCheckAgainstIgnoreHandledEventsMask(const GUIEventAdapter& ea,GUIActionAdapter& aa)
- {
- if (!ea.getHandled() ||
- (ea.getEventType() & _ignoreHandledEventsMask)==0)
- {
- bool handled = handle(ea,aa);
- if (handled) ea.setHandled(true);
- return handled;
- }
- else
- {
- return false;
- }
- }
复制代码
3、滚轮的消息处理从这里开始(viewer.cpp:946~955),
- for(osgGA::EventQueue::Events::iterator itr = events.begin();
- itr != events.end();
- ++itr)
- {
- osgGA::GUIEventAdapter* event = itr->get();
- if (_cameraManipulator.valid())
- {
- _cameraManipulator->handleWithCheckAgainstIgnoreHandledEventsMask( *event, *this);
- }
- }
复制代码
4、我的漫游器handle处理代码,无法获取到滚轮消息。
- bool MyDragger::handle( const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
- {
- if ( ea.getEventType() == osgGA::GUIEventAdapter::SCROLL )
- {
- float fScrollDelta = ea.getScrollingDeltaY();
- if ( ea.getScrollingMotion() == osgGA::GUIEventAdapter::ScrollingMotion::SCROLL_UP )
- {
- osg::notify(osg::NOTICE) << "SCROLL MOTION: " << ea.getScrollingMotion() << ", Delta(" << fScrollDelta << ")" << endl;
- }
- }
- else
- {
- osg::notify(osg::NOTICE) << "EventType : " << ea.getEventType() << endl;
- }
- return false;
- }
复制代码
|
|