mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
ui/input: change Events to return all events at once
Single stepping events only makes sense for widgets with complex state, e.g. the text.Editor. For the input.Events source, returning all events in a single Events call is sufficient and more natural for clients. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ package input
|
||||
// Events maps an event handler key to the events
|
||||
// available to the handler.
|
||||
type Events interface {
|
||||
Next(k Key) (Event, bool)
|
||||
Events(k Key) []Event
|
||||
}
|
||||
|
||||
// Key is the stable identifier for an event handler. For a handler h, the
|
||||
|
||||
+3
-7
@@ -19,14 +19,10 @@ type Queue struct {
|
||||
|
||||
type handlerEvents map[Key][]Event
|
||||
|
||||
func (q *Queue) Next(k Key) (Event, bool) {
|
||||
func (q *Queue) Events(k Key) []Event {
|
||||
events := q.handlers[k]
|
||||
if len(events) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
e := events[0]
|
||||
q.handlers[k] = events[1:]
|
||||
return e, true
|
||||
delete(q.handlers, k)
|
||||
return events
|
||||
}
|
||||
|
||||
func (q *Queue) Frame(ops *ui.Ops) {
|
||||
|
||||
Reference in New Issue
Block a user