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 <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-25 14:44:15 -06:00
parent 75314fcee2
commit 6dcebf205f
+3 -1
View File
@@ -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.