Documentation
¶
Overview ¶
Package gesture provides gesture events such as long presses and drags. These are higher level than underlying mouse and touch events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// Type is the gesture type.
Type Type
// Drag, LongPress and DoublePress are set when the gesture is recognized as
// a drag, etc.
//
// Note that these status fields can be lost during a gesture's events over
// time: LongPress can be set for the first press of a double press, but
// unset on the second press.
Drag bool
LongPress bool
DoublePress bool
// InitialPos is the initial position of the button press or touch that
// started this gesture.
InitialPos Point
// CurrentPos is the current position of the button or touch event.
CurrentPos Point
// Time is the event's time.
Time time.Time
}
Event is a gesture event.
type EventFilter ¶
type EventFilter struct {
EventDeque screen.EventDeque
// contains filtered or unexported fields
}
EventFilter generates gesture events from lower level mouse and touch events.
func (*EventFilter) Filter ¶
func (f *EventFilter) Filter(e interface{}) interface{}
Filter filters the event. It can return e, a different event, or nil to consume the event. It can also trigger side effects such as pushing new events onto its EventDeque.
type Type ¶
type Type uint8
Type describes the type of a touch event.
const ( // TypeStart and TypeEnd are the start and end of a gesture. A gesture // spans multiple events. TypeStart Type = 0 TypeEnd Type = 1 // TypeIsXxx is when the gesture is recognized as a long press, double // press or drag. For example, a mouse button press won't generate a // TypeIsLongPress immediately, but if a threshold duration passes without // the corresponding mouse button release, a TypeIsLongPress event is sent. // // Once a TypeIsXxx event is sent, the corresponding Event.Xxx bool field // is set for this and subsequent events. For example, a TypeTap event by // itself doesn't say whether or not it is a single tap or the first tap of // a double tap. If the app needs to distinguish these two sorts of taps, // it can wait until a TypeEnd or TypeIsDoublePress event is seen. If a // TypeEnd is seen before TypeIsDoublePress, or equivalently, if the // TypeEnd event's DoublePress field is false, the gesture is a single tap. // // These attributes aren't exclusive. A long press drag is perfectly valid. // // The uncommon "double press" instead of "double tap" terminology is // because, in this package, taps are associated with button releases, not // button presses. Note also that "double" really means "at least two". TypeIsLongPress Type = 10 TypeIsDoublePress Type = 11 TypeIsDrag Type = 12 // TypeTap and TypeDrag are tap and drag events. // // For 'flinging' drags, to simulate inertia, look to the Velocity field of // the TypeEnd event. // // TODO: implement velocity. TypeTap Type = 20 TypeDrag Type = 21 )
Click to show internal directories.
Click to hide internal directories.