ref: 1a9e03bf68dc38df757f26d84b10bb2398b1602a gio/ui/input/input.go -rw-r--r-- 976 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: Unlicense OR MIT

/*
Package input exposes a unified interface for receiving input
events.

For example:

	var queue input.Queue = ...

	for e, ok := queue.Next(h); ok; e, ok = queue.Next(h) {
		switch e.(type) {
			...
		}
	}

In general, handlers must be declared before events become
available. Other packages such as pointer and key provide
the means for declaring handlers for specific input types.

The following example marks a handler ready for key input:

	import gioui.org/ui/input
	import gioui.org/ui/key

	var ops ui.Ops
	var h *Handler = ...
	key.HandlerOp{Key: h}.Add(ops)

*/
package input

// Queue maps an event handler key to the events
// available to the handler.
type Queue interface {
	Next(k Key) (Event, bool)
}

// Key is the stable identifier for an event handler.
// For a handler h, the key is typically &h.
type Key interface{}

// Event is the marker interface for events.
type Event interface {
	ImplementsEvent()
}