io/router/key: add explicit tag to FocusOp; make last SoftKeyboardOp apply

The target of FocusOp is too subtle; be explicit instead and remove
any doubt.

Multiple SoftKeyboardOp in a single frame is rare, but if they do occur,
they should behave as if they were from separate frames: the last one
applies.

As a side-effect the key event router can be much simplified.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-01-22 16:04:10 +01:00
parent 95953b2ae0
commit e70a16c345
5 changed files with 41 additions and 106 deletions
+1 -1
View File
@@ -416,7 +416,7 @@ func (e *Editor) layout(gtx layout.Context) layout.Dimensions {
key.InputOp{Tag: &e.eventKey}.Add(gtx.Ops)
if e.requestFocus {
key.FocusOp{Focus: true}.Add(gtx.Ops)
key.FocusOp{Tag: &e.eventKey}.Add(gtx.Ops)
key.SoftKeyboardOp{Show: true}.Add(gtx.Ops)
}
e.requestFocus = false