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

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

public class DragRecognizer
extends MouseGestureRecognizer
implements HasAllDragHandlers

Recognizes and fires mouse-drag events.

Author:
Maryanovsky Alexander

Field Summary
static Condition<DragStartEvent> STANDARD_DRAG_CONDITION
          The condition for the standard drag - left mouse button and no keyboard modifiers.
 
Fields inherited from class com.maryanovsky.gwtutils.client.ui.mouse.gestures.MouseGestureRecognizer
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 mouseEventsSource)
          Creates a new DragRecognizer which will fire drag events with the specified source object and use the specified source of mouse events.
DragRecognizer(Object dragEventsSource, H mouseEventsSource, Condition<? super DragStartEvent> dragCondition)
          Creates a new DragRecognizer which will fire events with the specified source object, use the specified source of mouse 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 onMouseDown(MouseDownEvent event)
          Invoked when a mouse button is pressed.
protected  void onMouseMove(MouseMoveEvent event)
          Invoked when the mouse is moved.
protected  void onMouseUp(MouseUpEvent event)
          Invoked when a mouse button is released.
 
Methods inherited from class com.maryanovsky.gwtutils.client.ui.mouse.gestures.MouseGestureRecognizer
fireEvent, onMouseOut, onMouseOver, onMouseWheel, setMouseEventsSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD_DRAG_CONDITION

public static Condition<DragStartEvent> STANDARD_DRAG_CONDITION
The condition for the standard drag - left mouse button and no keyboard modifiers.

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 mouseEventsSource)
Creates a new DragRecognizer which will fire drag events with the specified source object and use the specified source of mouse 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 mouseEventsSource,
                      Condition<? super DragStartEvent> dragCondition)
Creates a new DragRecognizer which will fire events with the specified source object, use the specified source of mouse 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. For example, if you only want to recognize left-mouse-button drags, you would override this method and return evt.getButton() == NativeEvent.BUTTON_LEFT. The default implementation delegates the decision to the drag condition passed in the constructor.


onMouseDown

protected void onMouseDown(MouseDownEvent event)
Invoked when a mouse button is pressed.

Overrides:
onMouseDown in class MouseGestureRecognizer

onMouseUp

protected void onMouseUp(MouseUpEvent event)
Invoked when a mouse button is released.

Overrides:
onMouseUp in class MouseGestureRecognizer

onMouseMove

protected void onMouseMove(MouseMoveEvent event)
Invoked when the mouse is moved.

Overrides:
onMouseMove in class MouseGestureRecognizer