|
- void OsgWidget::keyPressEvent( QKeyEvent* event )
- {
- _gw->getEventQueue()->keyPress((osgGA::GUIEventAdapter::KeySymbol) * (event->text().toAscii().data()));
- }
复制代码
我重写的handle()如下:
-
- class PickModeHandler : public osgGA::GUIEventHandler
- {
- public:
- enum Modes
- {
- VIEW = 0,
- PICK
- };
- PickModeHandler():
- _mode(VIEW),
- _activeDragger(0)
- {
- }
- bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa,
- osg::Object*, osg::NodeVisitor*)
- {
- osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
- if (!view) return false;
- if (ea.getKey() == osgGA::GUIEventAdapter::KEY_F1 &&
- ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN &&
- _activeDragger == 0)
- {
- _mode = ! _mode;
- }
- if (ea.getKey()=='D')
- {
- QMessageBox msgBox;
- msgBox.setText("hello");
- msgBox.exec();
- }
- }
- }
复制代码
调用是在osgInit()中:
-
- _viewer.addEventHandler(new PickModeHandler());
复制代码
我遇到的问题是不能进行键盘响应:即我按下“D”键后没有反应,设置断点也不会中断。请问我的程序有问题吗? |
|