io/router: expand Router.Add to accept multiple events

Niver API and useful for testing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-27 09:08:56 +01:00
parent a995e9ea6c
commit 5a3ffad00a
+10 -8
View File
@@ -79,14 +79,16 @@ func (q *Router) Frame(ops *op.Ops) {
} }
} }
func (q *Router) Add(e event.Event) bool { func (q *Router) Add(events ...event.Event) bool {
switch e := e.(type) { for _, e := range events {
case profile.Event: switch e := e.(type) {
q.profile = e case profile.Event:
case pointer.Event: q.profile = e
q.pqueue.Push(e, &q.handlers) case pointer.Event:
case key.EditEvent, key.Event, key.FocusEvent: q.pqueue.Push(e, &q.handlers)
q.kqueue.Push(e, &q.handlers) case key.EditEvent, key.Event, key.FocusEvent:
q.kqueue.Push(e, &q.handlers)
}
} }
return q.handlers.HadEvents() return q.handlers.HadEvents()
} }