From 6dcebf205f2624978d238af7bf559c119972787b Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 25 Nov 2023 14:44:15 -0600 Subject: [PATCH] widget: show soft keyboard on focus We're about to replace the per-widget Focus methods with the client executing FocusCmd themselves. To ensure the soft keyboard is not forgotten, ask to show it automatically on focus. Signed-off-by: Elias Naur --- widget/editor.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/widget/editor.go b/widget/editor.go index 86a5a88b..9cfb00b8 100644 --- a/widget/editor.go +++ b/widget/editor.go @@ -390,6 +390,9 @@ func (e *Editor) processKey(gtx layout.Context) { e.focused = ke.Focus // Reset IME state. e.ime.imeState = imeState{} + if ke.Focus { + gtx.Execute(key.SoftKeyboardCmd{Show: true}) + } case key.Event: if !e.focused || ke.State != key.Press { break @@ -560,7 +563,6 @@ func (e *Editor) command(gtx layout.Context, k key.Event) { // Focus requests the input focus for the Editor. func (e *Editor) Focus(gtx layout.Context) { gtx.Execute(key.FocusCmd{Tag: e}) - gtx.Execute(key.SoftKeyboardCmd{Show: true}) } // Focused returns whether the editor is focused or not.