diff --git a/examples/osgkeyboard/osgkeyboard.cpp b/examples/osgkeyboard/osgkeyboard.cpp index 4313b0528..aa4f30872 100644 --- a/examples/osgkeyboard/osgkeyboard.cpp +++ b/examples/osgkeyboard/osgkeyboard.cpp @@ -17,6 +17,7 @@ */ #include +#include #include #include @@ -395,6 +396,7 @@ int main(int , char **) osg::ref_ptr keyboardModel = new KeyboardModel; + viewer.addEventHandler(new osgViewer::StatsHandler); viewer.addEventHandler(new KeyboardEventHandler(keyboardModel.get())); viewer.setSceneData( keyboardModel->getScene() ); diff --git a/src/osgGA/KeySwitchMatrixManipulator.cpp b/src/osgGA/KeySwitchMatrixManipulator.cpp index b6b69e96e..a7b7bf733 100644 --- a/src/osgGA/KeySwitchMatrixManipulator.cpp +++ b/src/osgGA/KeySwitchMatrixManipulator.cpp @@ -162,7 +162,9 @@ bool KeySwitchMatrixManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapt { if (!_current) return false; - if(ea.getEventType()==GUIEventAdapter::KEYDOWN) + bool handled = false; + + if (!ea.getHandled() && ea.getEventType()==GUIEventAdapter::KEYDOWN) { KeyManipMap::iterator it=_manips.find(ea.getKey()); @@ -178,11 +180,12 @@ bool KeySwitchMatrixManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapt _current = it->second.second; //_cameraManipChangeCallbacks.notify(this); - + + handled = true; } } - return _current->handle(ea,aa); + return _current->handle(ea,aa) || handled; } void KeySwitchMatrixManipulator::getUsage(osg::ApplicationUsage& usage) const diff --git a/src/osgGA/StateSetManipulator.cpp b/src/osgGA/StateSetManipulator.cpp index 1dfb37c71..a126b1284 100644 --- a/src/osgGA/StateSetManipulator.cpp +++ b/src/osgGA/StateSetManipulator.cpp @@ -63,6 +63,8 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa) (_stateset->getTextureMode(0,GL_TEXTURE_CUBE_MAP)&mode); } + if (ea.getHandled()) return false; + if(ea.getEventType()==GUIEventAdapter::KEYDOWN) { diff --git a/src/osgViewer/HelpHandler.cpp b/src/osgViewer/HelpHandler.cpp index a37a68e10..53e9536ed 100644 --- a/src/osgViewer/HelpHandler.cpp +++ b/src/osgViewer/HelpHandler.cpp @@ -40,6 +40,8 @@ bool HelpHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapt osgViewer::Viewer* viewer = dynamic_cast(&aa); if (!viewer) return false; + if (ea.getHandled()) return false; + switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::KEYDOWN): diff --git a/src/osgViewer/StatsHandler.cpp b/src/osgViewer/StatsHandler.cpp index f80ff0f68..3fb75ef0d 100644 --- a/src/osgViewer/StatsHandler.cpp +++ b/src/osgViewer/StatsHandler.cpp @@ -45,6 +45,8 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdap updateThreadingModelText(); } + if (ea.getHandled()) return false; + switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::KEYDOWN): diff --git a/src/osgViewer/ViewerEventHandlers.cpp b/src/osgViewer/ViewerEventHandlers.cpp index cebf328f6..85a88a938 100644 --- a/src/osgViewer/ViewerEventHandlers.cpp +++ b/src/osgViewer/ViewerEventHandlers.cpp @@ -67,9 +67,11 @@ bool WindowSizeHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActio return false; } + if (ea.getHandled()) return false; + switch(ea.getEventType()) { - case(osgGA::GUIEventAdapter::KEYUP): + case(osgGA::GUIEventAdapter::KEYUP): { if (_toggleFullscreen == true && ea.getKey() == _keyEventToggleFullscreen) { @@ -285,9 +287,11 @@ bool ThreadingHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIAction return false; } + if (ea.getHandled()) return false; + switch(ea.getEventType()) { - case(osgGA::GUIEventAdapter::KEYUP): + case(osgGA::GUIEventAdapter::KEYUP): { double delta = osg::Timer::instance()->delta_s(_tickOrLastKeyPress, osg::Timer::instance()->tick()); @@ -377,9 +381,33 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU return false; } + if(ea.getEventType()==osgGA::GUIEventAdapter::FRAME) + { + // Calculate our current delta (difference) in time between the last frame and + // current frame, regardless of whether we actually store a ControlPoint... + osg::Timer_t time = osg::Timer::instance()->tick(); + double delta = osg::Timer::instance()->delta_s(_lastFrameTime, time); + _lastFrameTime = time; + + // If our internal _delta is finally large enough to warrant a ControlPoint + // insertion, do so now. Be sure and reset the internal _delta, so we can start + // calculating when the next insert should happen. + if (_currentlyRecording && _delta >= _interval) + { + const osg::Matrixd& m = viewer->getCamera()->getInverseViewMatrix(); + _animPath->insert(osg::Timer::instance()->delta_s(_animStartTime, time), osg::AnimationPath::ControlPoint(m.getTrans(), m.getRotate())); + _delta = 0.0f; + } + else _delta += delta; + + return true; + } + + if (ea.getHandled()) return false; + switch(ea.getEventType()) { - case(osgGA::GUIEventAdapter::KEYUP): + case(osgGA::GUIEventAdapter::KEYUP): { // The user has requested to toggle recording. if (ea.getKey() ==_keyEventToggleRecord) @@ -462,28 +490,6 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU return true; } - break; - } - case(osgGA::GUIEventAdapter::FRAME): - { - // Calculate our current delta (difference) in time between the last frame and - // current frame, regardless of whether we actually store a ControlPoint... - osg::Timer_t time = osg::Timer::instance()->tick(); - double delta = osg::Timer::instance()->delta_s(_lastFrameTime, time); - _lastFrameTime = time; - - // If our internal _delta is finally large enough to warrant a ControlPoint - // insertion, do so now. Be sure and reset the internal _delta, so we can start - // calculating when the next insert should happen. - if (_currentlyRecording && _delta >= _interval) - { - const osg::Matrixd& m = viewer->getCamera()->getInverseViewMatrix(); - _animPath->insert(osg::Timer::instance()->delta_s(_animStartTime, time), osg::AnimationPath::ControlPoint(m.getTrans(), m.getRotate())); - _delta = 0.0f; - } - - else _delta += delta; - break; } default: