From e11ac9784cc841030a9c5a84ab138fa4f1eb9d46 Mon Sep 17 00:00:00 2001 From: Pierre Curto Date: Tue, 5 Oct 2021 19:30:26 +0200 Subject: [PATCH] gesture: add the Pressed method to Drag Signed-off-by: Pierre Curto --- gesture/gesture.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gesture/gesture.go b/gesture/gesture.go index 6dc508b1..890e3e4c 100644 --- a/gesture/gesture.go +++ b/gesture/gesture.go @@ -62,6 +62,7 @@ type ClickType uint8 // Drag detects drag gestures in the form of pointer.Drag events. type Drag struct { dragging bool + pressed bool pid pointer.ID start f32.Point grab bool @@ -339,6 +340,7 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event if !(e.Buttons == pointer.ButtonPrimary || e.Source == pointer.Touch) { continue } + d.pressed = true if d.dragging { continue } @@ -365,6 +367,7 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event } } case pointer.Release, pointer.Cancel: + d.pressed = false if !d.dragging || e.PointerID != d.pid { continue } @@ -381,6 +384,9 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event // Dragging reports whether it is currently in use. func (d *Drag) Dragging() bool { return d.dragging } +// Pressed returns whether a pointer is pressing. +func (d *Drag) Pressed() bool { return d.pressed } + func (a Axis) String() string { switch a { case Horizontal: