public abstract class AbstractGestureRecognizer extends Object implements GestureRecognizer
Modifier and Type | Class and Description |
---|---|
static class |
AbstractGestureRecognizer.ExtraTouchBehavior
Enum specifying how the gesture should treat 'extra' touches that occur, either to ignore them, or
cancel the whole gesture.
|
Modifier and Type | Field and Description |
---|---|
protected Map<Integer,TouchData> |
captured
Indicates touches that this gesture owns, and wants all info about, and keeps to itself
|
protected HasHandlers |
eventDelegate |
protected AbstractGestureRecognizer.ExtraTouchBehavior |
extraTouchBehavior |
protected Map<Integer,TouchData> |
interested
Indicates touches that this gesture wants to see when they end/cancel, but not move or preventDefault/stopPropagation
|
protected PointerEventsSupport |
pointerEventsSupport |
protected int |
touchCount |
Constructor and Description |
---|
AbstractGestureRecognizer(AbstractGestureRecognizer.ExtraTouchBehavior extraTouchBehavior,
int touchCount) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Ends recognition of the gesture, and fires any cancel events that apply.
|
protected void |
fireEvent(<any> event) |
List<TouchData> |
getTouches()
Gets all actively recognized touches that are being recognized by this gesture.
|
boolean |
handle(NativeEvent event)
Takes a browser event, and checks to see if it should decipher a gesture from it.
|
boolean |
handleCancel(NativeEvent cancelEvent)
Handles gesture cancel events
|
boolean |
handleEnd(NativeEvent endEvent)
Handles gesture end events
|
boolean |
handleMove(NativeEvent moveEvent)
Handles gesture move events
|
protected void |
handlePreventDefault(NativeEvent event)
Intended to allow subclasses to determine if preventDefault should be called
|
boolean |
handleStart(NativeEvent startEvent)
Handles the start of gesture.
|
protected abstract void |
onCancel(List<TouchData> touches)
Indicates that one or more touches have been canceled by the browser or by the gesture itself being canceled
(see #cancel).
|
protected abstract void |
onEnd(List<TouchData> touches)
Indicates that one or more touches have ended.
|
protected abstract void |
onMove(List<TouchData> touches)
Indicates that on or more touches are moving
|
protected abstract boolean |
onStart(TouchData startedTouch)
Indicates that a touch has started, giving the gesture the chance to exclusively handle this touch as it moves.
|
void |
setCaptured(TouchData touch,
boolean capture)
Indicates whether or not the gesture is interested in all events about the given touch, and that any event
about that touch should be preventDefault'd and stopPropagation'd.
|
void |
setDelegate(HasHandlers eventDelegate)
Sets delegate to receive Gesture events
|
void |
setInterest(TouchData touch,
boolean interest)
Indicates whether or not the gesture are interested in end/cancel events about the given touch.
|
void |
start(List<TouchData> touches)
Artificially starts a gesture
|
protected final Map<Integer,TouchData> interested
protected final Map<Integer,TouchData> captured
protected final int touchCount
protected final AbstractGestureRecognizer.ExtraTouchBehavior extraTouchBehavior
protected HasHandlers eventDelegate
protected PointerEventsSupport pointerEventsSupport
public AbstractGestureRecognizer(AbstractGestureRecognizer.ExtraTouchBehavior extraTouchBehavior, int touchCount)
public void cancel()
GestureRecognizer
cancel
in interface GestureRecognizer
public List<TouchData> getTouches()
GestureRecognizer
getTouches
in interface GestureRecognizer
public boolean handle(NativeEvent event)
GestureRecognizer
Takes a browser event, and checks to see if it should decipher a gesture from it.
Callers of this are expected to do their own vetting to decide if the given event should be handled by this gesture - for example, if a cell accepts a tap on one part of it and a longpress on another, the cell should determine where the touch events occur and send to the right recognizer accordingly.
handle
in interface GestureRecognizer
event
- the browser event to read for a gesture.public boolean handleStart(NativeEvent startEvent)
startEvent
- the start eventpublic boolean handleMove(NativeEvent moveEvent)
moveEvent
- the move eventpublic boolean handleCancel(NativeEvent cancelEvent)
cancelEvent
- the cancel eventpublic boolean handleEnd(NativeEvent endEvent)
endEvent
- the end eventpublic void setCaptured(TouchData touch, boolean capture)
Indicates whether or not the gesture is interested in all events about the given touch, and that any event
about that touch should be preventDefault'd and stopPropagation'd. Returning true
from #onStart
automatically captures the started touch.
Note that if the second argument is true, setInterest(touch, true) is implicit.
touch
- the touch datacapture
- whether to add or remove catpure on the given touchpublic void setDelegate(HasHandlers eventDelegate)
GestureRecognizer
setDelegate
in interface GestureRecognizer
eventDelegate
- the event handler delegatepublic void setInterest(TouchData touch, boolean interest)
Indicates whether or not the gesture are interested in end/cancel events about the given touch. Designed mostly for use in multi-touch gestures. If interest is declared, onCancel and onEnd will be invoked, but onMove will not.
Note that if the second argument is false, setCaptured(touch, false) is implicit.
touch
- the touch to be interested in, but not captureinterest
- whether to add or remove interest on the given touchpublic void start(List<TouchData> touches)
GestureRecognizer
start
in interface GestureRecognizer
touches
- the touches to be startedprotected void fireEvent(<any> event)
protected void handlePreventDefault(NativeEvent event)
event
- protected abstract boolean onStart(TouchData startedTouch)
startedTouch
- the touch that has begunprotected abstract void onMove(List<TouchData> touches)
touches
- protected abstract void onEnd(List<TouchData> touches)
touches
- data for the now-ended touches (as opposed to #getTouches which no longer has those entries)protected abstract void onCancel(List<TouchData> touches)
touches
- data for the now-canceled touches (as opposed to #getTouches which no longer has those entries)Copyright © 2020. All rights reserved.