From 38fca9ae130e0279a215c1a0f10efb83f760e98c Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 16 Jun 2024 15:19:41 +0200 Subject: [PATCH] widget: show software keyboard when a writable Editor is clicked Extracted from https://github.com/gioui/gio/pull/138 by Inkeliz. References: https://todo.sr.ht/~eliasnaur/gio/591 Signed-off-by: Elias Naur --- widget/editor.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/widget/editor.go b/widget/editor.go index 015c15de5..38783f037 100644 --- a/widget/editor.go +++ b/widget/editor.go @@ -289,6 +289,9 @@ func (e *Editor) processPointerEvent(gtx layout.Context, ev event.Event) (Editor Y: int(math.Round(float64(evt.Position.Y))), }) gtx.Execute(key.FocusCmd{Tag: e}) + if !e.ReadOnly { + gtx.Execute(key.SoftKeyboardCmd{Show: true}) + } if e.scroller.State() != gesture.StateFlinging { e.scrollCaret = true } @@ -395,7 +398,7 @@ func (e *Editor) processKey(gtx layout.Context) (EditorEvent, bool) { case key.FocusEvent: // Reset IME state. e.ime.imeState = imeState{} - if ke.Focus { + if ke.Focus && !e.ReadOnly { gtx.Execute(key.SoftKeyboardCmd{Show: true}) } case key.Event: