mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
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 <inkeliz@inkeliz.com>
This commit is contained in:
@@ -70,7 +70,7 @@ func NewWindow(win Callbacks, opts *Options) error {
|
|||||||
w.w = win
|
w.w = win
|
||||||
go func() {
|
go func() {
|
||||||
w.w.SetDriver(w)
|
w.w.SetDriver(w)
|
||||||
w.focus()
|
w.blur()
|
||||||
w.w.Event(system.StageEvent{Stage: system.StageRunning})
|
w.w.Event(system.StageEvent{Stage: system.StageRunning})
|
||||||
w.draw(true)
|
w.draw(true)
|
||||||
select {}
|
select {}
|
||||||
@@ -185,7 +185,7 @@ func (w *window) addEventListeners() {
|
|||||||
w.addEventListener(w.cnv, "touchstart", func(this js.Value, args []js.Value) interface{} {
|
w.addEventListener(w.cnv, "touchstart", func(this js.Value, args []js.Value) interface{} {
|
||||||
w.touchEvent(pointer.Press, args[0])
|
w.touchEvent(pointer.Press, args[0])
|
||||||
if w.requestFocus {
|
if w.requestFocus {
|
||||||
w.focus()
|
w.focus() // iOS can only focus inside a Touch event.
|
||||||
w.requestFocus = false
|
w.requestFocus = false
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -216,6 +216,7 @@ func (w *window) addEventListeners() {
|
|||||||
})
|
})
|
||||||
w.addEventListener(w.tarea, "blur", func(this js.Value, args []js.Value) interface{} {
|
w.addEventListener(w.tarea, "blur", func(this js.Value, args []js.Value) interface{} {
|
||||||
w.w.Event(key.FocusEvent{Focus: false})
|
w.w.Event(key.FocusEvent{Focus: false})
|
||||||
|
w.blur()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
w.addEventListener(w.tarea, "keydown", func(this js.Value, args []js.Value) interface{} {
|
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() {
|
func (w *window) blur() {
|
||||||
w.tarea.Call("blur")
|
w.tarea.Call("blur")
|
||||||
|
w.requestFocus = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) focus() {
|
func (w *window) focus() {
|
||||||
|
|||||||
Reference in New Issue
Block a user