public class PInputEvent extends Object
In addition is has methods to get the mouse position and delta in a variety of coordinate systems.
Last of all it provides access to the dispatch manager that can be queried to find the current mouse over, mouse focus, and keyboard focus.
Constructor and Description |
---|
PInputEvent(PInputManager inputManager,
InputEvent event)
Create an event with the given inputManager and based on the given swing
event.
|
Modifier and Type | Method and Description |
---|---|
int |
getButton()
Returns the mouse button value of the underlying mouse event.
|
PCamera |
getCamera()
Return the bottom most camera that is currently painting.
|
PDimension |
getCanvasDelta()
Return the delta between the last and current mouse position in PCanvas
coordinates.
|
Point2D |
getCanvasPosition()
Return the mouse position in PCanvas coordinates.
|
int |
getClickCount()
Returns the click count of the mouse event.
|
PComponent |
getComponent()
Get the canvas associated with the top camera.
|
PDimension |
getDelta()
Return the delta between the last and current mouse positions transformed
through the view transform of the bottom camera.
|
PDimension |
getDeltaRelativeTo(PNode nodeOnPath)
Return the delta between the last and current mouse positions relative to
a given node on the pick path.
|
PInputManager |
getInputManager()
Return the input manager that dispatched this event.
|
char |
getKeyChar()
Returns the character associated with a key event.
|
int |
getKeyCode()
Returns the key code associated with a key event.
|
int |
getKeyLocation()
Returns the location on the keyboard from which the key stroke
originated.
|
int |
getModifiers()
Returns the modifiers provided for the input event by swing.
|
int |
getModifiersEx()
Returns the extended modifiers provided for the input event by swing.
|
PPickPath |
getPath()
Return the PPickPath associated with this input event.
|
PNode |
getPickedNode()
Return the bottom node on the current pickpath, that is the picked node
furthest from the root node.
|
Point2D |
getPosition()
Return the mouse position transformed through the view transform of the
bottom camera.
|
Point2D |
getPositionRelativeTo(PNode nodeOnPath)
Return the mouse position relative to a given node on the pick path.
|
InputEvent |
getSourceSwingEvent()
Returns the underlying swing event that this PInputEvent is wrapping.
|
PCamera |
getTopCamera()
Return the topmost camera this is painting.
|
int |
getWheelRotation()
Returns the current value of the wheel rotation on Mouse Wheel Rotation
events.
|
long |
getWhen()
Returns the time at which the event was emitted.
|
boolean |
isActionKey()
Returns whether the key event involves the action key.
|
boolean |
isAltDown()
Returns whether the alt key is currently down.
|
boolean |
isControlDown()
Returns whether the control key is currently down.
|
boolean |
isFocusEvent()
Returns whether the underlying event is a Focus Event.
|
boolean |
isHandled()
Return true if another event handler has already handled this event.
|
boolean |
isKeyEvent()
Returns whether the underlying event is a KeyEvent.
|
boolean |
isLeftMouseButton()
Returns whether the mouse event involves the left mouse button.
|
boolean |
isMetaDown()
Returns whether the meta key is currently down.
|
boolean |
isMiddleMouseButton()
Returns whether the mouse event involves the middle mouse button.
|
boolean |
isMouseEnteredOrMouseExited()
Returns whether the underlying event is a mouse entered or exited event.
|
boolean |
isMouseEvent()
Returns whether the underlying event is a MouseEvent.
|
boolean |
isMouseWheelEvent()
Returns whether the underlying event is a Mouse Wheel Event.
|
boolean |
isPopupTrigger()
Returns whether or not this event is a popup menu trigger event for the
platform.
|
boolean |
isRightMouseButton()
Returns whether the mouse event involves the right mouse button.
|
boolean |
isShiftDown()
Returns whether the shift key is currently down.
|
void |
popCursor()
Removes the top most cursor from the cursor stack and sets it as the
current cursor.
|
void |
pushCursor(Cursor cursor)
Changes the cursor to the one provided and stores it on the cursor stack
for later retrieval.
|
void |
setHandled(boolean handled)
Set that this event has been handled by an event handler.
|
void |
setPath(PPickPath path)
Sets the PIckPath associated with this mouse event.
|
String |
toString()
Returns a string representation of this object for debugging purposes.
|
public PInputEvent(PInputManager inputManager, InputEvent event)
inputManager
- source of PInputEventevent
- underlying swing eventpublic void pushCursor(Cursor cursor)
cursor
- cursor to push on cursor stackpublic void popCursor()
public PCamera getCamera()
public PCamera getTopCamera()
public PComponent getComponent()
public PInputManager getInputManager()
public PPickPath getPath()
public void setPath(PPickPath path)
path
- path to associate with this mouse eventpublic PNode getPickedNode()
public int getKeyCode()
public char getKeyChar()
public int getKeyLocation()
public boolean isActionKey()
public int getModifiers()
public int getModifiersEx()
public int getClickCount()
public long getWhen()
public boolean isAltDown()
public boolean isControlDown()
public boolean isMetaDown()
public boolean isShiftDown()
public boolean isLeftMouseButton()
public boolean isMiddleMouseButton()
public boolean isRightMouseButton()
public boolean isHandled()
public void setHandled(boolean handled)
handled
- whether the event is markedpublic int getButton()
public int getWheelRotation()
public InputEvent getSourceSwingEvent()
public boolean isKeyEvent()
public boolean isMouseEvent()
public boolean isMouseWheelEvent()
public boolean isFocusEvent()
public boolean isMouseEnteredOrMouseExited()
public boolean isPopupTrigger()
Note: Popup menus are triggered differently on different systems.
Therefore, isPopupTrigger
should be checked in both
mousePressed
and mouseReleased
for proper
cross-platform functionality.
public Point2D getCanvasPosition()
public PDimension getCanvasDelta()
public Point2D getPositionRelativeTo(PNode nodeOnPath)
nodeOnPath
- node on the current PPickPathpublic PDimension getDeltaRelativeTo(PNode nodeOnPath)
nodeOnPath
- node from which to measurepublic Point2D getPosition()
public PDimension getDelta()
Copyright © 1995-2013 Piccolo2D. All Rights Reserved.