Deactivate alt modes on blur
This commit is contained in:
parent
737f4dbbb3
commit
af4e1aedff
1 changed files with 20 additions and 0 deletions
|
|
@ -329,11 +329,31 @@ function cleanupMouseHandlers() {
|
||||||
function setupKeyboardHandlers() {
|
function setupKeyboardHandlers() {
|
||||||
window.addEventListener('keydown', onKeyDown)
|
window.addEventListener('keydown', onKeyDown)
|
||||||
window.addEventListener('keyup', onKeyUp)
|
window.addEventListener('keyup', onKeyUp)
|
||||||
|
window.addEventListener('blur', onWindowBlur)
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupKeyboardHandlers() {
|
function cleanupKeyboardHandlers() {
|
||||||
window.removeEventListener('keydown', onKeyDown)
|
window.removeEventListener('keydown', onKeyDown)
|
||||||
window.removeEventListener('keyup', onKeyUp)
|
window.removeEventListener('keyup', onKeyUp)
|
||||||
|
window.removeEventListener('blur', onWindowBlur)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onWindowBlur() {
|
||||||
|
// Reset all modifier states when window loses focus
|
||||||
|
// This prevents "stuck" modifiers when user alt-tabs or switches tabs
|
||||||
|
const needsUpdate =
|
||||||
|
isCtrlPressed || isShiftPressed || isAltPressed || isSpacePressed || isMiddleMouseDown
|
||||||
|
|
||||||
|
isCtrlPressed = false
|
||||||
|
isShiftPressed = false
|
||||||
|
isAltPressed = false
|
||||||
|
isSpacePressed = false
|
||||||
|
isMiddleMouseDown = false
|
||||||
|
controls.enabled = false
|
||||||
|
|
||||||
|
if (needsUpdate) {
|
||||||
|
updateGizmoVisibility()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(event: KeyboardEvent) {
|
function onKeyDown(event: KeyboardEvent) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue