Documentation
¶
Overview ¶
Package pointer implements gesture recognizers.
Create the pointer recognizer in the Build function.
func (v *MyView) Build(ctx view.Context) view.Model {
tap := &pointer.TapGesture{
Count: 1,
OnEvent: func(e *pointer.TapEvent) {
if e.Kind == EventKindRecognized {
// Respond to pointer events. This callback occurs on main thread.
fmt.Println("view tapped")
}
},
}
...
Attach the recognizer to the view.
...
return view.Model{
Options: []view.Option{
pointer.GestureList{tap},
},
}
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ButtonEvent ¶
ButtonEvent is emitted by ButtonRecognizer, representing its current state.
type ButtonGesture ¶
type ButtonGesture struct {
Key int64
OnEvent func(e *ButtonEvent)
IgnoresScroll bool
}
ButtonGesture 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.
func (*ButtonGesture) Build ¶
func (r *ButtonGesture) Build() Model
func (*ButtonGesture) TouchKey ¶
func (r *ButtonGesture) TouchKey() int64
type EventKind ¶
type EventKind int
EventKind are the possible recognizer states
Discrete gestures:
EventKindPossible -> EventKindFailed EventKindPossible -> EventKindRecognized
Continuous gestures:
EventKindPossible -> EventKindFailed EventKindPossible -> EventKindRecognized 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 GestureList ¶
type GestureList []Gesture
func (GestureList) OptionKey ¶
func (r GestureList) OptionKey() string
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 PressGesture ¶
type PressGesture struct {
Key int64
MinDuration time.Duration
OnEvent func(e *PressEvent)
}
PressGesture is a continuous recognizer that detects single presses with a given duration.
func (*PressGesture) Build ¶
func (r *PressGesture) Build() Model
func (*PressGesture) TouchKey ¶
func (r *PressGesture) TouchKey() int64
type TapGesture ¶
PressRecognizer is a discrete recognizer that detects a number of taps.
func (*TapGesture) Build ¶
func (r *TapGesture) Build() Model
func (*TapGesture) TouchKey ¶
func (r *TapGesture) TouchKey() int64