com.maryanovsky.gwtutils.client.ui.mouse.gestures.click
Class ClickRecognizer

java.lang.Object
  extended by com.maryanovsky.gwtutils.client.ui.mouse.gestures.MouseGestureRecognizer
      extended by com.maryanovsky.gwtutils.client.ui.mouse.gestures.click.ClickRecognizer
All Implemented Interfaces:
HasClickHandlers

public class ClickRecognizer
extends MouseGestureRecognizer
implements HasClickHandlers

Recognizes and fires click events.

Author:
Maryanovsky Alexander

Field Summary
 
Fields inherited from class com.maryanovsky.gwtutils.client.ui.mouse.gestures.MouseGestureRecognizer
handlerManager
 
Constructor Summary
ClickRecognizer(Object clickEventsSource)
          Creates a new ClickRecognizer which will fire click events with the specified source object.
ClickRecognizer(Object clickEventsSource, Condition<? super ClickEvent> clickCondition)
          Creates a new ClickRecognizer which will fire click events with the specified source object and consult the specified click condition before doing so.
ClickRecognizer(Object clickEventsSource, H mouseEventsSource)
          Creates a new ClickRecognizer which will fire click events with the specified source object and use the specified source of mouse events.
ClickRecognizer(Object clickEventsSource, H mouseEventsSource, Condition<? super ClickEvent> clickCondition)
          Creates a new ClickRecognizer which will fire events with the specified source object, use the specified source of mouse events and consult the specified click condition before firing click events.
 
Method Summary
 HandlerRegistration addClickHandler(ClickHandler handler)
          Adds a click handler.
protected  boolean clickCondition(ClickEvent evt)
          Returns whether the specified ClickEvent should be delivered to the handlers.
protected  void onMouseDown(MouseDownEvent event)
          Invoked when a mouse button is pressed.
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, onMouseMove, onMouseOut, onMouseOver, onMouseWheel, setMouseEventsSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClickRecognizer

public ClickRecognizer(Object clickEventsSource)
Creates a new ClickRecognizer which will fire click events with the specified source object.


ClickRecognizer

public ClickRecognizer(Object clickEventsSource,
                       H mouseEventsSource)
Creates a new ClickRecognizer which will fire click events with the specified source object and use the specified source of mouse events.


ClickRecognizer

public ClickRecognizer(Object clickEventsSource,
                       Condition<? super ClickEvent> clickCondition)
Creates a new ClickRecognizer which will fire click events with the specified source object and consult the specified click condition before doing so.


ClickRecognizer

public ClickRecognizer(Object clickEventsSource,
                       H mouseEventsSource,
                       Condition<? super ClickEvent> clickCondition)
Creates a new ClickRecognizer which will fire events with the specified source object, use the specified source of mouse events and consult the specified click condition before firing click events. See the documentation of clickCondition(ClickEvent) for more information on the click condition.

Method Detail

addClickHandler

public HandlerRegistration addClickHandler(ClickHandler handler)
Adds a click handler.

Specified by:
addClickHandler in interface HasClickHandlers

clickCondition

protected boolean clickCondition(ClickEvent evt)
Returns whether the specified ClickEvent should be delivered to the handlers. This allows filtering click gestures to only those you really want. For example, if you only want to recognize right-clicks, you would override this method and return evt.getButton() == NativeEvent.BUTTON_RIGHT. The default implementation delegates the decision to the click 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