mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
ui/input: support single stepping through events
Change input.Events interface to return one event at a time until the queue is empty. Change text.Editor and gestures to match. Re-add Editor.Submit while we're here; we don't want to enable submit mode always. 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 {
|
||||
For(k Key) []Event
|
||||
Next(k Key) (Event, bool)
|
||||
}
|
||||
|
||||
// Key is the stable identifier for an event handler. For a handler h, the
|
||||
|
||||
+8
-2
@@ -19,8 +19,14 @@ type Queue struct {
|
||||
|
||||
type handlerEvents map[Key][]Event
|
||||
|
||||
func (q *Queue) For(k Key) []Event {
|
||||
return q.handlers[k]
|
||||
func (q *Queue) Next(k Key) (Event, bool) {
|
||||
events := q.handlers[k]
|
||||
if len(events) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
e := events[0]
|
||||
q.handlers[k] = events[1:]
|
||||
return e, true
|
||||
}
|
||||
|
||||
func (q *Queue) Frame(ops *ui.Ops) {
|
||||
|
||||
Reference in New Issue
Block a user