From b79c2dec79c171afda467626571c6c98f339ae0b Mon Sep 17 00:00:00 2001 From: Inkeliz Date: Fri, 11 Dec 2020 14:09:41 +0000 Subject: [PATCH] app/internal/window: [wasm] fix on-screen-keyboard Previously, the keyboard is open by default, even without any focus. Now, the keyboard will remain closed, until `.focus()` is called. That change also prevents the keyboard from reopening immediately after blur. Signed-off-by: Inkeliz --- app/internal/window/os_js.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/internal/window/os_js.go b/app/internal/window/os_js.go index acc0f5fd..1c9c58ff 100644 --- a/app/internal/window/os_js.go +++ b/app/internal/window/os_js.go @@ -70,7 +70,7 @@ func NewWindow(win Callbacks, opts *Options) error { w.w = win go func() { w.w.SetDriver(w) - w.focus() + w.blur() w.w.Event(system.StageEvent{Stage: system.StageRunning}) w.draw(true) select {} @@ -185,7 +185,7 @@ func (w *window) addEventListeners() { w.addEventListener(w.cnv, "touchstart", func(this js.Value, args []js.Value) interface{} { w.touchEvent(pointer.Press, args[0]) if w.requestFocus { - w.focus() + w.focus() // iOS can only focus inside a Touch event. w.requestFocus = false } return nil @@ -216,6 +216,7 @@ func (w *window) addEventListeners() { }) w.addEventListener(w.tarea, "blur", func(this js.Value, args []js.Value) interface{} { w.w.Event(key.FocusEvent{Focus: false}) + w.blur() return nil }) w.addEventListener(w.tarea, "keydown", func(this js.Value, args []js.Value) interface{} { @@ -256,6 +257,7 @@ func (w *window) flushInput() { func (w *window) blur() { w.tarea.Call("blur") + w.requestFocus = false } func (w *window) focus() {