|
楼主 |
发表于 2013-4-27 15:32:37
|
显示全部楼层
liuzhiyu123 发表于 2013-4-27 15:07
应该是要处理的事件的类型吧
嗯嗯,刚才试验了一下,是要处理的事件类型,只是函数名起个Mask有点误导人的意思。
不过想追问下,Widget和Label对事件的响应有什么区别么?
如下代码中:
自定义的Widget- struct myWidget:osgWidget::Widget()
- {
- public:
- myWidget():osgWidget::Widget("","")
- {
- setImage("**.png");
- setTextureCoord(*,*,*);
- ......//设置纹理坐标
- setColor(1.0f,0.0f,0.0f,0.5f);
- setEventMask(osgWidget::EVENT_ALL);
- }
- bool mousePush(*,*,*)
- {
- setColor(1.0f,0.0f,0.0f,0.5f);
- return true;
- }
- }
复制代码 自定义的Label- struct myLabel:osgWidget::Label()
- {
- public:
- myWidget():osgWidget::Widget("","")
- {
- setLabel("MyLabel");
- setColor(1.0f,0.0f,0.0f,0.5f);
- setEventMask(osgWidget::EVENT_ALL);
- }
- bool mousePush(*,*,*)
- {
- setColor(1.0f,0.0f,0.0f,0.5f);
- return true;
- }
- }
复制代码 运行时发现自定义的Mylabel可以正常响应事件,而MyWidget却不能响应,跟踪代码发现MyWidget根本没有进入到mousePush函数中,请问这是什么原因呢? |
|