mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
io/event: move event types from package ui to its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -81,31 +81,5 @@ To maintain a constant visual size across platforms and displays, always
|
||||
use dps or sps to define user interfaces. Only use pixels for derived
|
||||
values.
|
||||
|
||||
Events
|
||||
|
||||
The Queue interface is the protocol for receiving external events.
|
||||
|
||||
For example:
|
||||
|
||||
var queue ui.Queue = ...
|
||||
|
||||
for _, e := range queue.Events(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 event types.
|
||||
|
||||
The following example declares a handler ready for key input:
|
||||
|
||||
import gioui.org/io/key
|
||||
|
||||
ops := new(ui.Ops)
|
||||
var h *Handler = ...
|
||||
key.InputOp{Key: h}.Add(ops)
|
||||
|
||||
*/
|
||||
package ui
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package ui
|
||||
|
||||
// Queue maps an event handler key to the events
|
||||
// available to the handler.
|
||||
type Queue interface {
|
||||
// Events returns the available events for a
|
||||
// Key.
|
||||
Events(k Key) []Event
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
Reference in New Issue
Block a user