ui: add package input for merged input

To avoid passing a queue type for each kind of input (pointer, key),
introduce package input for mapping a handler key to all input events.

Future input sources can be added without changes to programs, and
as an added bonus, event ordering is preserved across input sources.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-07 21:41:09 +02:00
parent 28dd25736f
commit a35118d522
10 changed files with 172 additions and 130 deletions
+2 -4
View File
@@ -11,9 +11,9 @@ import (
"gioui.org/ui"
"gioui.org/ui/app/internal/gpu"
"gioui.org/ui/input"
"gioui.org/ui/internal/ops"
"gioui.org/ui/key"
"gioui.org/ui/pointer"
)
type WindowOptions struct {
@@ -238,9 +238,7 @@ func (w *Window) event(e Event) {
needAck := false
needRedraw := false
switch e := e.(type) {
case pointer.Event:
needRedraw = true
case key.Event:
case input.Event:
needRedraw = true
case *Command:
needAck = true