Package edu.umd.cs.piccolo
Class PInputManager
java.lang.Object
edu.umd.cs.piccolo.event.PBasicInputEventHandler
edu.umd.cs.piccolo.PInputManager
- All Implemented Interfaces:
PInputEventListener,PRoot.InputSource,EventListener
PInputManager is responsible for dispatching PInputEvents to node's
event listeners. Events are dispatched from PRoot's processInputs method.
- Version:
- 1.0
- Author:
- Jesse Grosjean
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a PInputManager and sets positions (last, current) to the origin (0,0). -
Method Summary
Modifier and TypeMethodDescriptionprotected voidFires events whenever the mouse moves from PNode to PNode.protected PInputEventcreateInputEvent(InputEvent event) Creates aPInputEventbased on the given SwingInputEvent.
Has been introduced for enabling the "injection" of specialized implementations (subclasses) via overriding this factory method, and, hence, is called instead of callingPInputEvent(PInputManager, InputEvent)directly.protected voiddispatchEventToListener(PInputEvent event, int type, PInputEventListener listener) Dispatches the given event to the listener, or does nothing if listener is null.Returns the position of the current canvas event.Return the node that currently has the keyboard focus.Returns the position on the Canvas of the last event.Return the current Pick Path under the mouse focus.Return the node the the mouse is currently over.voidkeyPressed(PInputEvent event) Will get called whenever a key has been pressed down.voidkeyReleased(PInputEvent event) Will get called whenever a key has been released.voidkeyTyped(PInputEvent event) Will be called at the end of a full keystroke (down then up).voidmouseClicked(PInputEvent event) Will be called at the end of a full click (mouse pressed followed by mouse released).voidmouseDragged(PInputEvent event) Will be called when a drag is occurring.voidmouseEntered(PInputEvent event) Will be invoked when the mouse enters a specified region.voidmouseExited(PInputEvent event) Will be invoked when the mouse leaves a specified region.voidmouseMoved(PInputEvent event) Will be called when the mouse is moved.voidmousePressed(PInputEvent event) Will be called when a mouse button is pressed down.voidmouseReleased(PInputEvent event) Will be called when any mouse button is released.voidmouseWheelRotated(PInputEvent event) This method is invoked when the mouse wheel is rotated.voidThis method is invoked when the mouse wheel is rotated by a block.voidprocessEventFromCamera(InputEvent event, int type, PCamera camera) Flags the given event as needing to be processed.voidCauses the system to process any pending Input Events.voidsetKeyboardFocus(PInputEventListener eventHandler) Set the node that should receive key events.voidsetMouseFocus(PPickPath path) Sets the current Pick Path under the mouse focus.voidsetMouseOver(PPickPath path) Records the path which is directly below the mouse.Methods inherited from class edu.umd.cs.piccolo.event.PBasicInputEventHandler
acceptsEvent, getEventFilter, keyboardFocusGained, keyboardFocusLost, paramString, processEvent, setEventFilter
-
Constructor Details
-
PInputManager
public PInputManager()Creates a PInputManager and sets positions (last, current) to the origin (0,0).
-
-
Method Details
-
getKeyboardFocus
Return the node that currently has the keyboard focus. This node receives the key events.- Returns:
- the current keyboard focus
-
setKeyboardFocus
Set the node that should receive key events.- Parameters:
eventHandler- sets the keyboard event focus, may be null
-
getMouseFocus
Return the current Pick Path under the mouse focus. This will return the path that received the current mouse pressed event, or null if the mouse is not pressed. The mouse focus gets mouse dragged events even what the mouse is not over the mouse focus.- Returns:
- the current Pick Path under the mouse focus
-
setMouseFocus
Sets the current Pick Path under the mouse focus. The mouse focus gets mouse dragged events even when the mouse is not over the mouse focus.- Parameters:
path- the new mouse focus
-
getMouseOver
Return the node the the mouse is currently over.- Returns:
- the path over which the mouse currently is
-
setMouseOver
Records the path which is directly below the mouse.- Parameters:
path- path over which the mouse has been moved
-
getLastCanvasPosition
Returns the position on the Canvas of the last event.- Returns:
- position of last canvas event
-
getCurrentCanvasPosition
Returns the position of the current canvas event.- Returns:
- position of current canvas event
-
keyPressed
Will get called whenever a key has been pressed down. Subclasses should override this method to implement their own behavior.- Overrides:
keyPressedin classPBasicInputEventHandler- Parameters:
event- the event representing the keystroke
-
keyReleased
Will get called whenever a key has been released. Subclasses should override this method to implement their own behavior.- Overrides:
keyReleasedin classPBasicInputEventHandler- Parameters:
event- the event representing the keystroke
-
keyTyped
Will be called at the end of a full keystroke (down then up). Subclasses should override this method to implement their own behavior.- Overrides:
keyTypedin classPBasicInputEventHandler- Parameters:
event- object which can be queried for the event's details
-
mouseClicked
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.- Overrides:
mouseClickedin classPBasicInputEventHandler- Parameters:
event- object which can be queried for the event's details
-
mouseWheelRotated
This method is invoked when the mouse wheel is rotated. Subclasses should override this method to implement their own behavior.- Overrides:
mouseWheelRotatedin classPBasicInputEventHandler- Parameters:
event- an object that can be queries to discover the event's details
-
mouseWheelRotatedByBlock
This method is invoked when the mouse wheel is rotated by a block. Subclasses should override this method to implement their own behavior.- Overrides:
mouseWheelRotatedByBlockin classPBasicInputEventHandler- Parameters:
event- an object that can be queries to discover the event's details
-
mouseDragged
Will be called when a drag is occurring. This is system dependent. Subclasses should override this method to implement their own behavior.- Overrides:
mouseDraggedin classPBasicInputEventHandler- Parameters:
event- object which can be queried for the event's details
-
mouseEntered
Will be invoked when the mouse enters a specified region. Subclasses should override this method to implement their own behavior.- Overrides:
mouseEnteredin classPBasicInputEventHandler- Parameters:
event- object which can be queried for the event's details
-
mouseExited
Will be invoked when the mouse leaves a specified region. Subclasses should override this method to implement their own behavior.- Overrides:
mouseExitedin classPBasicInputEventHandler- Parameters:
event- object which can be queried for the event's details
-
mouseMoved
Will be called when the mouse is moved. Subclasses should override this method to implement their own behavior.- Overrides:
mouseMovedin classPBasicInputEventHandler- Parameters:
event- object which can be queried for event details
-
mousePressed
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.- Overrides:
mousePressedin classPBasicInputEventHandler- Parameters:
event- object which can be queried for the event's details
-
mouseReleased
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.- Overrides:
mouseReleasedin classPBasicInputEventHandler- Parameters:
event- object which can be queried for event details
-
checkForMouseEnteredAndExited
Fires events whenever the mouse moves from PNode to PNode.- Parameters:
event- to check to see if the top node has changed.
-
processInput
public void processInput()Causes the system to process any pending Input Events.- Specified by:
processInputin interfacePRoot.InputSource
-
createInputEvent
Creates aPInputEventbased on the given SwingInputEvent.
Has been introduced for enabling the "injection" of specialized implementations (subclasses) via overriding this factory method, and, hence, is called instead of callingPInputEvent(PInputManager, InputEvent)directly.- Parameters:
event- the SwingInputEventto wrap- Returns:
- the desired
PInputEvent
-
processEventFromCamera
Flags the given event as needing to be processed.- Parameters:
event- the event to be processedtype- type of event to be processedcamera- camera from which the event was dispatched
-
dispatchEventToListener
Dispatches the given event to the listener, or does nothing if listener is null.- Parameters:
event- event to be dispatchedtype- type of event to dispatchlistener- target of dispatch
-