edu.umd.cs.piccolo.event
Class PBasicInputEventHandler

java.lang.Object
  extended by edu.umd.cs.piccolo.event.PBasicInputEventHandler
All Implemented Interfaces:
PInputEventListener, EventListener
Direct Known Subclasses:
PDragSequenceEventHandler, PInputManager

public class PBasicInputEventHandler
extends Object
implements PInputEventListener

PBasicInputEventHandler is the standard class in Piccolo that is used to register for mouse and keyboard events on a PNode. Note the events that you get depends on the node that you have registered with. For example you will only get mouse moved events when the mouse is over the node that you have registered with, not when the mouse is over some other node.

Version:
1.0
Author:
Jesse Grosjean

Constructor Summary
PBasicInputEventHandler()
          Constructs a PBasicInputEventHandler with a wide open event filter.
 
Method Summary
 boolean acceptsEvent(PInputEvent event, int type)
          Returns true if the event would be dispatched if passed to processEvent.
 PInputEventFilter getEventFilter()
          Returns the event filter responsible for filtering incoming events.
 void keyboardFocusGained(PInputEvent event)
          This method is invoked when a node gains the keyboard focus.
 void keyboardFocusLost(PInputEvent event)
          This method is invoked when a node loses the keyboard focus.
 void keyPressed(PInputEvent event)
          Will get called whenever a key has been pressed down.
 void keyReleased(PInputEvent event)
          Will get called whenever a key has been released.
 void keyTyped(PInputEvent event)
          Will be called at the end of a full keystroke (down then up).
 void mouseClicked(PInputEvent event)
          Will be called at the end of a full click (mouse pressed followed by mouse released).
 void mouseDragged(PInputEvent event)
          Will be called when a drag is occurring.
 void mouseEntered(PInputEvent event)
          Will be invoked when the mouse enters a specified region.
 void mouseExited(PInputEvent event)
          Will be invoked when the mouse leaves a specified region.
 void mouseMoved(PInputEvent event)
          Will be called when the mouse is moved.
 void mousePressed(PInputEvent event)
          Will be called when a mouse button is pressed down.
 void mouseReleased(PInputEvent event)
          Will be called when any mouse button is released.
 void mouseWheelRotated(PInputEvent event)
          This method is invoked when the mouse wheel is rotated.
 void mouseWheelRotatedByBlock(PInputEvent event)
          This method is invoked when the mouse wheel is rotated by a block.
protected  String paramString()
          Deprecated. see http://code.google.com/p/piccolo2d/issues/detail?id=99
 void processEvent(PInputEvent event, int type)
          Dispatches a generic event to a more specific method.
 void setEventFilter(PInputEventFilter newEventFilter)
          Changes this event handler's filter to the one provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PBasicInputEventHandler

public PBasicInputEventHandler()
Constructs a PBasicInputEventHandler with a wide open event filter.

Method Detail

processEvent

public void processEvent(PInputEvent event,
                         int type)
Dispatches a generic event to a more specific method. Sparing subclasses from the dispatch logic.

Specified by:
processEvent in interface PInputEventListener
Parameters:
event - the event to be dispatched
type - Swing event type of the underlying Swing event

acceptsEvent

public boolean acceptsEvent(PInputEvent event,
                            int type)
Returns true if the event would be dispatched if passed to processEvent.

Parameters:
event - event being tested for acceptance
type - Swing event type of underlying swing event
Returns:
true if the event would be dispatched

getEventFilter

public PInputEventFilter getEventFilter()
Returns the event filter responsible for filtering incoming events.

Returns:
this handler's InputEventFilter

setEventFilter

public void setEventFilter(PInputEventFilter newEventFilter)
Changes this event handler's filter to the one provided.

Parameters:
newEventFilter - filter to use for this input event handler

keyPressed

public void keyPressed(PInputEvent event)
Will get called whenever a key has been pressed down. Subclasses should override this method to implement their own behavior.

Parameters:
event - the event representing the keystroke

keyReleased

public void keyReleased(PInputEvent event)
Will get called whenever a key has been released. Subclasses should override this method to implement their own behavior.

Parameters:
event - the event representing the keystroke

keyTyped

public void keyTyped(PInputEvent event)
Will be called at the end of a full keystroke (down then up). Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for the event's details

mouseClicked

public void mouseClicked(PInputEvent event)
Will be called at the end of a full click (mouse pressed followed by mouse released). Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for the event's details

mousePressed

public void mousePressed(PInputEvent event)
Will be called when a mouse button is pressed down. Should two buttons be pressed simultaneously, it will dispatch two of these in an unspecified order. Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for the event's details

mouseDragged

public void mouseDragged(PInputEvent event)
Will be called when a drag is occurring. This is system dependent. Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for the event's details

mouseEntered

public void mouseEntered(PInputEvent event)
Will be invoked when the mouse enters a specified region. Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for the event's details

mouseExited

public void mouseExited(PInputEvent event)
Will be invoked when the mouse leaves a specified region. Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for the event's details

mouseMoved

public void mouseMoved(PInputEvent event)
Will be called when the mouse is moved. Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for event details

mouseReleased

public void mouseReleased(PInputEvent event)
Will be called when any mouse button is released. Should two or more buttons be released simultaneously, this method will be called multiple times. Subclasses should override this method to implement their own behavior.

Parameters:
event - object which can be queried for event details

mouseWheelRotated

public void mouseWheelRotated(PInputEvent event)
This method is invoked when the mouse wheel is rotated. Subclasses should override this method to implement their own behavior.

Parameters:
event - an object that can be queries to discover the event's details

mouseWheelRotatedByBlock

public void mouseWheelRotatedByBlock(PInputEvent event)
This method is invoked when the mouse wheel is rotated by a block. Subclasses should override this method to implement their own behavior.

Parameters:
event - an object that can be queries to discover the event's details

keyboardFocusGained

public void keyboardFocusGained(PInputEvent event)
This method is invoked when a node gains the keyboard focus. Subclasses should override this method to implement their own behavior.

Parameters:
event - an object that can be queries to discover the event's details

keyboardFocusLost

public void keyboardFocusLost(PInputEvent event)
This method is invoked when a node loses the keyboard focus. Subclasses should override this method to implement their own behavior.

Parameters:
event - an object that can be queries to discover the event's details

paramString

protected String paramString()
Deprecated. see http://code.google.com/p/piccolo2d/issues/detail?id=99

Returns:
empty string since this method is deprecated


Copyright © 1995-2011 Piccolo2D. All Rights Reserved.