com.maryanovsky.gwtutils.client.ui.touch.gestures.drag
Class DragRecognizer

java.lang.Object
  extended by com.maryanovsky.gwtutils.client.ui.touch.gestures.TouchGestureRecognizer
      extended by com.maryanovsky.gwtutils.client.ui.touch.gestures.drag.DragRecognizer
All Implemented Interfaces:
HasAllDragHandlers, HasDragCancelHandlers, HasDragEndHandlers, HasDragMoveHandlers, HasDragStartHandlers

public class DragRecognizer
extends TouchGestureRecognizer
implements HasAllDragHandlers

Recognizes and fires drag events.

Author:
Maryanovsky Alexander

Field Summary
 
Fields inherited from class com.maryanovsky.gwtutils.client.ui.touch.gestures.TouchGestureRecognizer
handlerManager
 
Constructor Summary
DragRecognizer(Object dragEventsSource)
          Creates a new DragRecognizer which will fire drag events with the specified source object.
DragRecognizer(Object dragEventsSource, Condition<? super DragStartEvent> dragCondition)
          Creates a new DragRecognizer which will fire drag events with the specified source object and consult the specified drag condition before doing so.
DragRecognizer(Object dragEventsSource, H touchEventsSource)
          Creates a new DragRecognizer which will fire events with the specified source object and use the specified source of touch events.
DragRecognizer(Object dragEventsSource, H touchEventsSource, Condition<? super DragStartEvent> dragCondition)
          Creates a new DragRecognizer which will fire events with the specified source object, use the specified source of touch events and consult the specified drag condition before firing the drag event(s).
 
Method Summary
 HandlerRegistration addDragCancelHandler(DragCancelHandler handler)
          Adds a drag cancel handler.
 HandlerRegistration addDragEndHandler(DragEndHandler handler)
          Adds a drag end handler.
 HandlerRegistration addDragMoveHandler(DragMoveHandler handler)
          Adds a drag move handler.
 HandlerRegistration addDragStartHandler(DragStartHandler handler)
          Adds a drag start handler.
protected  boolean dragCondition(DragStartEvent evt)
          Returns whether the specified DragStartEvent and the drag events that follow it in the drag gesture should be delivered to the handlers.
protected  void onTouchCancel(TouchCancelEvent evt)
          Invoked when a touch event is canceled.
protected  void onTouchEnd(TouchEndEvent evt)
          Invoked when a finger touching the screen is lifted.
protected  void onTouchMove(TouchMoveEvent evt)
          Invoked when a finger touching the screen is moved.
protected  void onTouchStart(TouchStartEvent evt)
          Invoked when a touch starts.
 
Methods inherited from class com.maryanovsky.gwtutils.client.ui.touch.gestures.TouchGestureRecognizer
fireEvent, setTouchEventsSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragRecognizer

public DragRecognizer(Object dragEventsSource)
Creates a new DragRecognizer which will fire drag events with the specified source object.


DragRecognizer

public DragRecognizer(Object dragEventsSource,
                      H touchEventsSource)
Creates a new DragRecognizer which will fire events with the specified source object and use the specified source of touch events.


DragRecognizer

public DragRecognizer(Object dragEventsSource,
                      Condition<? super DragStartEvent> dragCondition)
Creates a new DragRecognizer which will fire drag events with the specified source object and consult the specified drag condition before doing so.


DragRecognizer

public DragRecognizer(Object dragEventsSource,
                      H touchEventsSource,
                      Condition<? super DragStartEvent> dragCondition)
Creates a new DragRecognizer which will fire events with the specified source object, use the specified source of touch events and consult the specified drag condition before firing the drag event(s). See the documentation of dragCondition(DragStartEvent) for more information on the drag condition.

Method Detail

addDragStartHandler

public HandlerRegistration addDragStartHandler(DragStartHandler handler)
Adds a drag start handler.

Specified by:
addDragStartHandler in interface HasDragStartHandlers

addDragMoveHandler

public HandlerRegistration addDragMoveHandler(DragMoveHandler handler)
Adds a drag move handler.

Specified by:
addDragMoveHandler in interface HasDragMoveHandlers

addDragEndHandler

public HandlerRegistration addDragEndHandler(DragEndHandler handler)
Adds a drag end handler.

Specified by:
addDragEndHandler in interface HasDragEndHandlers

addDragCancelHandler

public HandlerRegistration addDragCancelHandler(DragCancelHandler handler)
Adds a drag cancel handler.

Specified by:
addDragCancelHandler in interface HasDragCancelHandlers

dragCondition

protected boolean dragCondition(DragStartEvent evt)
Returns whether the specified DragStartEvent and the drag events that follow it in the drag gesture should be delivered to the handlers. This allows filtering drag gestures to only those you really want. The default implementation delegates the decision to the drag condition passed in the constructor.


onTouchStart

protected void onTouchStart(TouchStartEvent evt)
Invoked when a touch starts.

Overrides:
onTouchStart in class TouchGestureRecognizer

onTouchMove

protected void onTouchMove(TouchMoveEvent evt)
Invoked when a finger touching the screen is moved.

Overrides:
onTouchMove in class TouchGestureRecognizer

onTouchEnd

protected void onTouchEnd(TouchEndEvent evt)
Invoked when a finger touching the screen is lifted.

Overrides:
onTouchEnd in class TouchGestureRecognizer

onTouchCancel

protected void onTouchCancel(TouchCancelEvent evt)
Invoked when a touch event is canceled.

Overrides:
onTouchCancel in class TouchGestureRecognizer