查看: 2141|回复: 5

【求助】MyGUI界面无响应

[复制链接]

该用户从未签到

发表于 2012-10-18 11:20:08 | 显示全部楼层 |阅读模式
本帖最后由 xulin_2005 于 2012-10-18 11:26 编辑

MyGUI界面无响应问题

问题描述:
       我在将MyGUI集成到OSG中后,发现点击MyGUI的窗口无响应,在跟踪了injectMouseMove这些鼠标响应的事件后,怀疑是配置文件的问题,但看不出来是哪出了错,下面给出一些截图、代码和堆栈调用信息,求高人出手相助!!!

截图:
MyGUI集成问题.png

堆栈调用:
  1. MyGUIEngine_d.dll!MyGUI::Widget::getLayerItemByPoint(int _left=-80, int _top=461) 行490 C++
  2. MyGUIEngine_d.dll!MyGUI::Widget::getLayerItemByPoint(int _left=0, int _top=541) 行506 + 0x45 字节 C++
  3. MyGUIEngine_d.dll!MyGUI::LayerNode::getLayerItemByPoint(int _left=0, int _top=541) 行152 + 0x24 字节 C++
  4. MyGUIEngine_d.dll!MyGUI::OverlappedLayer::getLayerItemByPoint(int _left=0, int _top=541) 行149 + 0x24 字节 C++
  5. MyGUIEngine_d.dll!MyGUI::LayerManager::getWidgetFromPoint(int _left=0, int _top=541) 行215 + 0x24 字节 C++
  6. MyGUIEngine_d.dll!MyGUI::InputManager::injectMouseMove(int _absx=0, int _absy=541, int _absz=0) 行137 + 0x14 字节 C++
  7. Construct.exe!SHH3D::MYGUIManager::updateEvents() 行205 + 0x23 字节 C++
  8. Construct.exe!SHH3D::MYGUIManager::drawImplementation(osg::RenderInfo & renderInfo={...}) 行152 + 0x12 字节 C++
复制代码
关键代码段

  1.         ILayerItem* Widget::getLayerItemByPoint(int _left, int _top) const
  2.         {
  3.                 if (!mEnabled
  4.                         || !mVisible
  5.                         || (!getNeedMouseFocus() && !getInheritsPick())
  6.                         || !_checkPoint(_left, _top)
  7.                         || !isMaskPickInside(IntPoint(_left - mCoord.left, _top - mCoord.top), mCoord)
  8.                         )
  9.                         return nullptr;   // <-------------------------- 每次都是在测出返回false,发现这个函数是被嵌套调用的,所以只要有一层未能满足,就会返回失败。

  10.                 for (VectorWidgetPtr::const_reverse_iterator widget = mWidgetChild.rbegin(); widget != mWidgetChild.rend(); ++widget)
  11.                 {
  12.                         if ((*widget)->mWidgetStyle == WidgetStyle::Popup)
  13.                                 continue;

  14.                         ILayerItem* item = (*widget)->getLayerItemByPoint(_left - mCoord.left, _top - mCoord.top);
  15.                         if (item != nullptr)
  16.                                 return item;
  17.                 }
  18.                 for (VectorWidgetPtr::const_reverse_iterator widget = mWidgetChildSkin.rbegin(); widget != mWidgetChildSkin.rend(); ++widget)
  19.                 {
  20.                         ILayerItem* item = (*widget)->getLayerItemByPoint(_left - mCoord.left, _top - mCoord.top);
  21.                         if (item != nullptr)
  22.                                 return item;
  23.                 }

  24.                 return getInheritsPick() ? nullptr : const_cast<Widget*>(this);
  25.         }

复制代码

该用户从未签到

发表于 2012-10-18 14:24:54 | 显示全部楼层
消息映射做了么?

该用户从未签到

 楼主| 发表于 2012-10-18 14:41:20 | 显示全部楼层
liuzhiyu123 发表于 2012-10-18 14:24
消息映射做了么?

应该是加了。
MYGUIManager::updateEvents()已经调用了,这个是在MYGUIHandler::handle()处理中添加的,所有的事件消息都响应了,这里只是举InputManager::injectMouseMove()的处理为例。

该用户从未签到

发表于 2012-10-18 14:49:52 | 显示全部楼层
把您的消息映射那里贴出来,估计是映射的值有问题

该用户从未签到

发表于 2012-10-18 14:50:17 | 显示全部楼层
把您的消息映射那里贴出来,估计是映射的值有问题

该用户从未签到

 楼主| 发表于 2012-10-19 08:45:34 | 显示全部楼层
这部分是接收的消息处理

  1.         bool MYGUIHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
  2.         {
  3.                 int width = ea.getWindowWidth(), height = ea.getWindowHeight();
  4.                 switch ( ea.getEventType() )
  5.                 {
  6.                 case osgGA::GUIEventAdapter::RESIZE:
  7.                         if ( _camera.valid() )
  8.                         {
  9.                                 _camera->setProjectionMatrix( osg::Matrixd::ortho2D(0.0, width, 0.0, height) );
  10.                                 _camera->setViewport( 0.0, 0.0, width, height );
  11.                         }
  12.                         break;
  13.                 default:
  14.                         break;
  15.                 }

  16.                 // As MyGUI handle all events within the OpenGL context, we have to record the event here
  17.                 // and process it later in the draw implementation
  18.                 if ( (ea.getEventType()!=osgGA::GUIEventAdapter::FRAME) && _manager )
  19.                         _manager->pushEvent( &ea );
  20.                 return _manager->_bHanlded;
  21.         }
复制代码

这部分是Event队列处理

  1. void MYGUIManager::updateEvents() const
  2.         {
  3.                 unsigned int size = _eventsToHandle.size();
  4.                 for ( unsigned int i=0; i<size; ++i )
  5.                 {
  6.                         const osgGA::GUIEventAdapter& ea = *(_eventsToHandle.front());
  7.                         int x = ea.getX(), y = ea.getY(), key = ea.getKey();
  8.                         if ( ea.getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS )
  9.                                 y = ea.getWindowHeight() - y;

  10.                         switch ( ea.getEventType() )
  11.                         {
  12.                         case osgGA::GUIEventAdapter::PUSH:
  13.                                 _bHanlded = MyGUI::InputManager::getInstance().injectMousePress( x, y, convertMouseButton(ea.getButton()));
  14.                                 break;
  15.                         case osgGA::GUIEventAdapter::RELEASE:
  16.                                 _bHanlded = MyGUI::InputManager::getInstance().injectMouseRelease( x, y, convertMouseButton(ea.getButton()) );
  17.                                 break;
  18.                         case osgGA::GUIEventAdapter::DRAG:
  19.                         case osgGA::GUIEventAdapter::MOVE:
  20.                                 _bHanlded = MyGUI::InputManager::getInstance().injectMouseMove( x, y, 0 );
  21.                                 break;
  22.                         case osgGA::GUIEventAdapter::KEYDOWN:
  23.                                 if ( key<127 )
  24.                                         _bHanlded = MyGUI::InputManager::getInstance().injectKeyPress( convertKeyCode(key), (char)key );
  25.                                 else
  26.                                         _bHanlded = MyGUI::InputManager::getInstance().injectKeyPress( convertKeyCode(key) );
  27.                                 break;
  28.                         case osgGA::GUIEventAdapter::IME:
  29.                                 _bHanlded = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::None, (MyGUI::Char)ea.getCode());
  30.                                 break;
  31.                         case osgGA::GUIEventAdapter::KEYUP:
  32.                                 _bHanlded = MyGUI::InputManager::getInstance().injectKeyRelease( convertKeyCode(key) );
  33.                                 break;
  34.                         case osgGA::GUIEventAdapter::RESIZE:
  35.                                 _platform->getRenderManagerPtr()->setViewSize( ea.getWindowWidth(), ea.getWindowHeight() );
  36.                                 break;
  37.                         default:
  38.                                 break;
  39.                         }
  40.                         const_cast<MYGUIManager*>(this)->_eventsToHandle.pop();
  41.                 }
  42.         }

复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表