all: [API] deliver events one at a time to allow fine-grained event processing

Processing one event at a time allows a widget to execute commands after
the event that triggered it, instead of after all matching events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-24 16:46:39 -06:00
parent bce1dbd654
commit 88f5ac9cb9
14 changed files with 233 additions and 187 deletions
+5 -1
View File
@@ -163,7 +163,11 @@ func (b *Clickable) Update(gtx layout.Context) []Click {
if b.focused {
filters = append(filters, key.Filter{Name: key.NameReturn}, key.Filter{Name: key.NameSpace})
}
for _, e := range gtx.Events(&b.keyTag, filters...) {
for {
e, ok := gtx.Event(&b.keyTag, filters...)
if !ok {
break
}
switch e := e.(type) {
case key.FocusEvent:
b.focused = e.Focus