Back to

package gesture

v0.0.0 (278e9bc)
Latest Go to latest
Published: Jun 3, 2020 | Licenses: MIT, Unlicense | Module:


Package gesture implements common pointer gestures.

Gestures accept low level pointer Events from an event Queue and detect higher level actions such as clicks and scrolling.


type Axis

type Axis uint8
const (
	Horizontal Axis = iota

func (Axis) String

func (a Axis) String() string

type Click

type Click struct {
	// contains filtered or unexported fields

Click detects click gestures in the form of ClickEvents.

func (*Click) Add

func (c *Click) Add(ops *op.Ops)

Add the handler to the operation list to receive click events.

func (*Click) Events

func (c *Click) Events(q event.Queue) []ClickEvent

Events returns the next click event, if any.

func (*Click) State

func (c *Click) State() ClickState

State reports the click state.

type ClickEvent

type ClickEvent struct {
	Type      ClickType
	Position  f32.Point
	Source    pointer.Source
	Modifiers key.Modifiers
	// NumClicks records successive clicks occurring
	// within a short duration of each other.
	NumClicks int

ClickEvent represent a click action, either a TypePress for the beginning of a click or a TypeClick for a completed click.

type ClickState

type ClickState uint8
const (
	// StateNormal is the default click state.
	StateNormal ClickState = iota
	// StateFocused is reported when a pointer
	// is hovering over the handler.
	// StatePressed is then a pointer is pressed.

func (ClickState) String

func (cs ClickState) String() string

type ClickType

type ClickType uint8
const (
	// TypePress is reported for the first pointer
	// press.
	TypePress ClickType = iota
	// TypeClick is reported when a click action
	// is complete.

func (ClickType) String

func (ct ClickType) String() string

type Scroll

type Scroll struct {
	// contains filtered or unexported fields

Scroll detects scroll gestures and reduces them to scroll distances. Scroll recognizes mouse wheel movements as well as drag and fling touch gestures.

func (*Scroll) Add

func (s *Scroll) Add(ops *op.Ops)

Add the handler to the operation list to receive scroll events.

func (*Scroll) Scroll

func (s *Scroll) Scroll(cfg unit.Converter, q event.Queue, t time.Time, axis Axis) int

Scroll detects the scrolling distance from the available events and ongoing fling gestures.

func (*Scroll) State

func (s *Scroll) State() ScrollState

State reports the scroll state.

func (*Scroll) Stop

func (s *Scroll) Stop()

Stop any remaining fling movement.

type ScrollState

type ScrollState uint8
const (
	// StateIdle is the default scroll state.
	StateIdle ScrollState = iota
	// StateDrag is reported during drag gestures.
	// StateFlinging is reported when a fling is
	// in progress.

func (ScrollState) String

func (s ScrollState) String() string
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier