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:
Gordon Klaus
2020-06-03 15:22:48 +02:00
committed by Elias Naur
parent 4484674ab1
commit 9d2a6c48d8
7 changed files with 102 additions and 19 deletions
+17 -3
View File
@@ -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)