diff --git a/apps/opencs/view/render/cameracontroller.cpp b/apps/opencs/view/render/cameracontroller.cpp index 68f0c76ef..dc356827a 100644 --- a/apps/opencs/view/render/cameracontroller.cpp +++ b/apps/opencs/view/render/cameracontroller.cpp @@ -308,6 +308,17 @@ namespace CSVRender getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix()); } + void FreeCameraController::resetInput() + { + mFast = false; + mLeft = false; + mRight = false; + mForward = false; + mBackward = false; + mRollLeft = false; + mRollRight = false; + } + void FreeCameraController::yaw(double value) { getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalUp); @@ -535,6 +546,17 @@ namespace CSVRender getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix()); } + void OrbitCameraController::resetInput() + { + mFast = false; + mLeft = false; + mRight =false; + mUp = false; + mDown = false; + mRollLeft = false; + mRollRight = false; + } + void OrbitCameraController::onActivate() { mInitialized = false; diff --git a/apps/opencs/view/render/cameracontroller.hpp b/apps/opencs/view/render/cameracontroller.hpp index 575bbb4ea..f9021f04b 100644 --- a/apps/opencs/view/render/cameracontroller.hpp +++ b/apps/opencs/view/render/cameracontroller.hpp @@ -51,6 +51,8 @@ namespace CSVRender virtual void update(double dt) = 0; + virtual void resetInput() = 0; + protected: virtual void onActivate(){} @@ -87,6 +89,8 @@ namespace CSVRender void update(double dt); + void resetInput(); + private: void yaw(double value); @@ -126,6 +130,8 @@ namespace CSVRender void update(double dt); + void resetInput(); + private: void onActivate(); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 93d3be865..b2b5b30d6 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -175,6 +175,7 @@ SceneWidget::SceneWidget(boost::shared_ptr resourceSys // Recieve mouse move event even if mouse button is not pressed setMouseTracking(true); + setFocusPolicy(Qt::StrongFocus); /// \todo make shortcut configurable QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut); @@ -291,6 +292,11 @@ void SceneWidget::mouseMoveEvent (QMouseEvent *event) mPrevMouseY = event->y(); } +void SceneWidget::focusOutEvent (QFocusEvent *event) +{ + mCurrentCamControl->resetInput(); +} + void SceneWidget::wheelEvent(QWheelEvent *event) { mCurrentCamControl->handleMouseMoveEvent("t-navi", event->delta(), 0); diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index dfda1f96c..4df49543a 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -96,6 +96,7 @@ namespace CSVRender virtual void wheelEvent (QWheelEvent *event); virtual void keyPressEvent (QKeyEvent *event); virtual void keyReleaseEvent (QKeyEvent *event); + virtual void focusOutEvent (QFocusEvent *event); /// \return Is \a key a button mapping setting? (ignored otherwise) virtual bool storeMappingSetting (const CSMPrefs::Setting *setting); diff --git a/extern/osgQt/GraphicsWindowQt.cpp b/extern/osgQt/GraphicsWindowQt.cpp index 78a2ae616..17150bed4 100644 --- a/extern/osgQt/GraphicsWindowQt.cpp +++ b/extern/osgQt/GraphicsWindowQt.cpp @@ -245,7 +245,6 @@ bool GraphicsWindowQt::init( QWidget* parent, const QGLWidget* shareWidget, Qt:: // initialize widget properties _widget->setAutoBufferSwap( false ); _widget->setMouseTracking( true ); - _widget->setFocusPolicy( Qt::WheelFocus ); _widget->setGraphicsWindow( this ); useCursor( _traits->useCursor );