mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/ui: bug fix: reset key states when the window is not focused on macOS
Updates #2183
This commit is contained in:
parent
e81c46a0d7
commit
7b6ce7dcba
@ -36,6 +36,13 @@ func (i *Input) updateKeys(window *glfw.Window) {
|
|||||||
i.keyPressed = map[C.CGKeyCode]bool{}
|
i.keyPressed = map[C.CGKeyCode]bool{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if window.GetAttrib(glfw.Focused) != glfw.True {
|
||||||
|
for _, cgKey := range uiKeyToCGKey {
|
||||||
|
i.keyPressed[C.CGKeyCode(cgKey)] = false
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Record the key states instead of calling CGEventSourceKeyState every time at IsKeyPressed.
|
// Record the key states instead of calling CGEventSourceKeyState every time at IsKeyPressed.
|
||||||
// There is an assumption that the key states never change during one tick.
|
// There is an assumption that the key states never change during one tick.
|
||||||
// Without this assumption, some functions in inpututil would not work correctly.
|
// Without this assumption, some functions in inpututil would not work correctly.
|
||||||
|
Loading…
Reference in New Issue
Block a user