diff --git a/src/viewer/scene/CameraControl/CameraControl.js b/src/viewer/scene/CameraControl/CameraControl.js index 0ecab2c743..8c552b3448 100644 --- a/src/viewer/scene/CameraControl/CameraControl.js +++ b/src/viewer/scene/CameraControl/CameraControl.js @@ -649,6 +649,8 @@ class CameraControl extends Component { snapToEdge: DEFAULT_SNAP_EDGE, snapRadius: DEFAULT_SNAP_PICK_RADIUS, + keyboardEnabledOnlyIfMouseover: true, + // Rotation dragRotationRate: 360.0, @@ -959,6 +961,24 @@ class CameraControl extends Component { get snapRadius() { return this._configs.snapRadius; } + + /** + * If `true`, the keyboard shortcuts are enabled ONLY if the mouse is over the canvas. + * + * @param {boolean} value + */ + set keyboardEnabledOnlyIfMouseover(value) { + this._configs.keyboardEnabledOnlyIfMouseover = !!value; + } + + /** + * Gets whether the keyboard shortcuts are enabled ONLY if the mouse is over the canvas or ALWAYS. + * + * @returns {boolean} + */ + get keyboardEnabledOnlyIfMouseover() { + return this._configs.keyboardEnabledOnlyIfMouseover; + } /** * Sets the current navigation mode. diff --git a/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js b/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js index a1bb852033..ede42ce3a5 100644 --- a/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +++ b/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js @@ -29,7 +29,7 @@ class KeyboardAxisViewHandler { return; } - if (!states.mouseover) { + if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) { return; } diff --git a/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js b/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js index 2076aaff1a..ec82fec9ee 100644 --- a/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +++ b/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js @@ -22,7 +22,7 @@ class KeyboardPanRotateDollyHandler { if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) { return; } - if (!states.mouseover) { + if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) { return; } keyDownMap[keyCode] = true; @@ -53,7 +53,7 @@ class KeyboardPanRotateDollyHandler { return; } - if (!states.mouseover) { + if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) { return; }