com.maryanovsky.gwtutils.client
Class UserEventManager

java.lang.Object
  extended by com.maryanovsky.gwtutils.client.UserEventManager
All Implemented Interfaces:
SourcesMouseEvents, SourcesMouseWheelEvents

public class UserEventManager
extends Object
implements SourcesMouseEvents, SourcesMouseWheelEvents

Converts low-level user events fired by the browser (mouse, keyboard events) to high level events (mouse clicked, key pressed) and invokes a specified action when such an event occurs.

Author:
Maryanovsky Alexander

Constructor Summary
UserEventManager(Widget actionTarget, SourcesMouseEvents mouseEventsSource, SourcesMouseWheelEvents mouseWheelEventsSource)
          Creates a new UserEventManager to listen to events from the specified sources.
 
Method Summary
 void addMouseListener(MouseListener listener)
          SourcesMouseEvents implementation.
 void addMouseWheelListener(MouseWheelListener listener)
          SourcesMouseWheelEvents implementation.
 void removeMouseListener(MouseListener listener)
          SourcesMouseEvents implementation.
 void removeMouseWheelListener(MouseWheelListener listener)
          SourcesMouseWheelEvents implementation.
 void setClickAction(ClickAction clickAction)
          Sets the action invoked when the (left) mouse button is clicked once.
 void setDoubleClickAction(ClickAction doubleClickAction)
          Sets the action invoked when the (left) mouse button is clicked twice.
 void setDragAction(DragAction dragAction)
          Sets the action invoked when the mouse is dragged.
 void setMiddleClickAction(ClickAction middleClickAction)
          Sets the action invoked when the middle mouse button is clicked.
 void setMoveAction(MoveAction moveAction)
          Sets the action invoked when the mouse is moved without any buttons being pressed.
 void setRightClickAction(ClickAction rightClickAction)
          Sets the action invoked when the right mouse button is clicked.
 void setTripleClickAction(ClickAction tripleClickAction)
          Sets the action invoked when the (left) mouse button is clicked three times.
 void setWheelAction(WheelAction wheelAction)
          Sets the action invoked when the mouse wheel is scrolled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserEventManager

public UserEventManager(Widget actionTarget,
                        SourcesMouseEvents mouseEventsSource,
                        SourcesMouseWheelEvents mouseWheelEventsSource)
Creates a new UserEventManager to listen to events from the specified sources. Either of the sources may be null, in which case the corresponding class of low-level events is not handled. If mouseSource is null, however, not only will mouse events not be reported, but the mouse coordinates reported for other events are unspecified.

Parameters:
actionTarget - The widget passed as the target to the actions.
mouseEventsSource - The source for mouse events.
mouseWheelEventsSource - The source for mouse wheel events.
Method Detail

setClickAction

public void setClickAction(ClickAction clickAction)
Sets the action invoked when the (left) mouse button is clicked once. Use null to specify that no action is to be invoked.


setDoubleClickAction

public void setDoubleClickAction(ClickAction doubleClickAction)
Sets the action invoked when the (left) mouse button is clicked twice. Use null to specify that no action is to be invoked.


setTripleClickAction

public void setTripleClickAction(ClickAction tripleClickAction)
Sets the action invoked when the (left) mouse button is clicked three times. Use null to specify that no action is to be invoked.


setRightClickAction

public void setRightClickAction(ClickAction rightClickAction)
Sets the action invoked when the right mouse button is clicked. Use null to specify that no action is to be invoked. Note that to enable right click detection, you need to call UiUtils.disableContextMenu(Element) on the source widget or one of its ancestors.


setMiddleClickAction

public void setMiddleClickAction(ClickAction middleClickAction)
Sets the action invoked when the middle mouse button is clicked. Use null to specify that no action is to be invoked.


setMoveAction

public void setMoveAction(MoveAction moveAction)
Sets the action invoked when the mouse is moved without any buttons being pressed. Use null to specify that no action is to be invoked.


setDragAction

public void setDragAction(DragAction dragAction)
Sets the action invoked when the mouse is dragged. Use null to specify that no action is to be invoked.


setWheelAction

public void setWheelAction(WheelAction wheelAction)
Sets the action invoked when the mouse wheel is scrolled. Use null to specify that no action is to be invoked.


addMouseListener

public void addMouseListener(MouseListener listener)
SourcesMouseEvents implementation.

Specified by:
addMouseListener in interface SourcesMouseEvents

removeMouseListener

public void removeMouseListener(MouseListener listener)
SourcesMouseEvents implementation.

Specified by:
removeMouseListener in interface SourcesMouseEvents

addMouseWheelListener

public void addMouseWheelListener(MouseWheelListener listener)
SourcesMouseWheelEvents implementation.

Specified by:
addMouseWheelListener in interface SourcesMouseWheelEvents

removeMouseWheelListener

public void removeMouseWheelListener(MouseWheelListener listener)
SourcesMouseWheelEvents implementation.

Specified by:
removeMouseWheelListener in interface SourcesMouseWheelEvents