touch

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package constraint implements touch recognizers.

Create the touch recognizer in the Build function.

func (v *MyView) Build(ctx *view.Context) view.Model {
	tap := &touch.TapRecognizer{
		Count: 1,
		OnTouch: func(e *touch.TapEvent) {
			// Respond to touch events. This callback occurs on main thread.
			fmt.Println("view touched")
		},
	}
	...

Attach the recognizer to the view.

	...
 	return view.Model{
 		Options: []view.Option{
 			touch.RecognizerList{tap},
 		},
 	}
 }

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ButtonEvent

type ButtonEvent struct {
	Timestamp time.Time
	Inside    bool
	Kind      EventKind
}

ButtonEvent is emitted by ButtonRecognizer, representing its current state.

type ButtonRecognizer

type ButtonRecognizer struct {
	OnTouch       func(e *ButtonEvent)
	IgnoresScroll bool
}

ButtonRecognizer is a discrete recognizer that mimics the behavior of a button. The recognizer will fail if the touch ends outside of the view's bounds.

type EventKind

type EventKind int

EventKind are the possible recognizer states

Discrete gestures:

EventKindPossible -> EventKindFailed
EventKindPossible -> EventKindRecognized

Continuous gestures:

EventKindPossible -> EventKindChanged(optionally) -> EventKindFailed
EventKindPossible -> EventKindChanged(optionally) -> EventKindRecognized
const (
	// Finger is down, but before gesture has been recognized.
	EventKindPossible EventKind = iota
	// After the continuous gesture has been recognized, while the finger is still down. Only for continuous recognizers.
	EventKindChanged
	// Gesture recognition failed or cancelled.
	EventKindFailed
	// Gesture recognition succeded.
	EventKindRecognized
)

type PressEvent

type PressEvent struct {
	Kind      EventKind // TODO(KD): Does this work?
	Timestamp time.Time
	Position  layout.Point
	Duration  time.Duration
}

PressEvent is emitted by PressRecognizer, representing its current state.

type PressRecognizer

type PressRecognizer struct {
	MinDuration time.Duration
	OnTouch     func(e *PressEvent)
}

PressRecognizer is a continuous recognizer that detects single presses with a given duration.

type Recognizer

type Recognizer interface {
	// contains filtered or unexported methods
}

type RecognizerList

type RecognizerList []Recognizer

func (RecognizerList) OptionsKey

func (r RecognizerList) OptionsKey() string

type TapEvent

type TapEvent struct {
	Timestamp time.Time
	Position  layout.Point
}

TapEvent is emitted by TapRecognizer, representing its current state.

type TapRecognizer

type TapRecognizer struct {
	Count   int
	OnTouch func(*TapEvent)
}

PressRecognizer is a discrete recognizer that detects a number of taps.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL