1 // SPDX-License-Identifier: Unlicense OR MIT
2 3 /*
4 Package event contains the types for event handling.
5 6 The Queue interface is the protocol for receiving external events.
7 8 For example:
9 10 var queue event.Queue = ...
11 12 for _, e := range queue.Events(h) {
13 switch e.(type) {
14 ...
15 }
16 }
17 18 In general, handlers must be declared before events become
19 available. Other packages such as pointer and key provide
20 the means for declaring handlers for specific event types.
21 22 The following example declares a handler ready for key input:
23 24 import github.com/p9c/p9/pkg/gel/gio/io/key
25 26 ops := new(op.Ops)
27 var h *Handler = ...
28 key.InputOp{Tag: h}.Add(ops)
29 30 */
31 package event
32 33 // Queue maps an event handler key to the events
34 // available to the handler.
35 type Queue interface {
36 // Events returns the available events for an
37 // event handler tag.
38 Events(t Tag) []Event
39 }
40 41 // Tag is the stable identifier for an event handler.
42 // For a handler h, the tag is typically &h.
43 type Tag interface{}
44 45 // Event is the marker interface for events.
46 type Event interface {
47 ImplementsEvent()
48 }
49