internal/ui: bug fix: recover the cursor mode when capturing fails

Closes #2764
This commit is contained in:
Hajime Hoshi 2024-09-15 18:34:10 +09:00
parent 429e0d8183
commit 6f3f567b58

View File

@ -539,6 +539,10 @@ func (u *UserInterface) init() error {
}))
document.Call("addEventListener", "pointerlockerror", js.FuncOf(func(this js.Value, args []js.Value) any {
js.Global().Get("console").Call("error", "pointerlockerror event is fired. 'sandbox=\"allow-pointer-lock\"' might be required at an iframe. This function on browsers must be called as a result of a gestural interaction or orientation change.")
if u.cursorMode == CursorModeCaptured {
u.recoverCursorMode()
}
u.recoverCursorPosition()
return nil
}))
document.Call("addEventListener", "fullscreenerror", js.FuncOf(func(this js.Value, args []js.Value) any {