Added checking of GUIEventAdpter::getHandled().

This commit is contained in:
Robert Osfield 2007-07-03 13:26:48 +00:00
parent dd628a9829
commit 7f0b3144ea
6 changed files with 45 additions and 28 deletions

View File

@ -17,6 +17,7 @@
*/
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osg/io_utils>
#include <osg/MatrixTransform>
@ -395,6 +396,7 @@ int main(int , char **)
osg::ref_ptr<KeyboardModel> keyboardModel = new KeyboardModel;
viewer.addEventHandler(new osgViewer::StatsHandler);
viewer.addEventHandler(new KeyboardEventHandler(keyboardModel.get()));
viewer.setSceneData( keyboardModel->getScene() );

View File

@ -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

View File

@ -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)
{

View File

@ -40,6 +40,8 @@ bool HelpHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapt
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
if (!viewer) return false;
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):

View File

@ -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):

View File

@ -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: