mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
internal/ui: bug fix: reset some input states on blur events on browsers
Closes #2874
This commit is contained in:
parent
9147e7b21d
commit
d04d6271d0
@ -416,3 +416,13 @@ var uiKeyToJSKey = map[Key]js.Value{
|
||||
KeyNumpad8: js.ValueOf("8"),
|
||||
KeyNumpad9: js.ValueOf("9"),
|
||||
}
|
||||
|
||||
func (i *InputState) resetForBlur() {
|
||||
for j := range i.KeyPressed {
|
||||
i.KeyPressed[j] = false
|
||||
}
|
||||
for j := range i.MouseButtonPressed {
|
||||
i.MouseButtonPressed[j] = false
|
||||
}
|
||||
i.Touches = i.Touches[:0]
|
||||
}
|
||||
|
@ -693,6 +693,12 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
|
||||
go u.appendDroppedFiles(data)
|
||||
return nil
|
||||
}))
|
||||
|
||||
// Blur
|
||||
v.Call("addEventListener", "blur", js.FuncOf(func(this js.Value, args []js.Value) any {
|
||||
u.inputState.resetForBlur()
|
||||
return nil
|
||||
}))
|
||||
}
|
||||
|
||||
func (u *UserInterface) appendDroppedFiles(data js.Value) {
|
||||
|
Loading…
Reference in New Issue
Block a user