all: [API] replace tag parameter of Source.Event with per-filter tags

Until now, every event has had a particular target. We're about to simplify
key event delivery to match the first matching filter, so there is no
longer a global meaning to the tag argument to Source.Event.

Add fields to filters to specify their target tags.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-26 12:58:10 -06:00
parent 496fc3cc82
commit d9a007586c
16 changed files with 195 additions and 115 deletions
+6 -3
View File
@@ -65,13 +65,16 @@ func (e *Enum) Update(gtx layout.Context) bool {
}
}
filters := []event.Filter{
key.FocusFilter{},
key.FocusFilter{Target: &state.tag},
}
if e.focused && e.focus == state.key {
filters = append(filters, key.Filter{Name: key.NameReturn}, key.Filter{Name: key.NameSpace})
filters = append(filters,
key.Filter{Target: &state.tag, Name: key.NameReturn},
key.Filter{Target: &state.tag, Name: key.NameSpace},
)
}
for {
ev, ok := gtx.Event(&state.tag, filters...)
ev, ok := gtx.Event(filters...)
if !ok {
break
}