mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
io/pointer: add InputOp.Types to specify which types of events to receive
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
This commit is contained in:
+17
-3
@@ -8,6 +8,23 @@ object such as a finger.
|
||||
The InputOp operation is used to declare a handler ready for pointer
|
||||
events. Use an event.Queue to receive events.
|
||||
|
||||
Types
|
||||
|
||||
Only events that match a specified list of types are delivered to a handler.
|
||||
|
||||
For example, to receive Press, Move, and Release events (but not Enter,
|
||||
Leave, or Scroll):
|
||||
|
||||
var ops op.Ops
|
||||
var h *Handler = ...
|
||||
|
||||
pointer.InputOp{
|
||||
Tag: h,
|
||||
Types: pointer.Press | pointer.Move | pointer.Release,
|
||||
}.Add(ops)
|
||||
|
||||
Cancel events are always delivered.
|
||||
|
||||
Areas
|
||||
|
||||
The area operations are used for specifying the area where
|
||||
@@ -15,9 +32,6 @@ subsequent InputOp are active.
|
||||
|
||||
For example, to set up a rectangular hit area:
|
||||
|
||||
var ops op.Ops
|
||||
var h *Handler = ...
|
||||
|
||||
r := image.Rectangle{...}
|
||||
pointer.Rect(r).Add(ops)
|
||||
pointer.InputOp{Tag: h}.Add(ops)
|
||||
|
||||
@@ -56,6 +56,8 @@ type InputOp struct {
|
||||
// Grab, if set, request that the handler get
|
||||
// Grabbed priority.
|
||||
Grab bool
|
||||
// Types is a bitwise-or of event types to receive.
|
||||
Types Type
|
||||
}
|
||||
|
||||
// PassOp sets the pass-through mode.
|
||||
@@ -83,7 +85,7 @@ type areaKind uint8
|
||||
const (
|
||||
// A Cancel event is generated when the current gesture is
|
||||
// interrupted by other handlers or the system.
|
||||
Cancel Type = iota
|
||||
Cancel Type = (1 << iota) >> 1
|
||||
// Press of a pointer.
|
||||
Press
|
||||
// Release of a pointer.
|
||||
@@ -157,6 +159,7 @@ func (h InputOp) Add(o *op.Ops) {
|
||||
if h.Grab {
|
||||
data[1] = 1
|
||||
}
|
||||
data[2] = byte(h.Types)
|
||||
}
|
||||
|
||||
func (op PassOp) Add(o *op.Ops) {
|
||||
|
||||
Reference in New Issue
Block a user