Package edu.umd.cs.piccolo.event
Class PInputEvent
java.lang.Object
edu.umd.cs.piccolo.event.PInputEvent
PInputEvent is used to notify PInputEventListeners of keyboard and
mouse input. It has methods for normal event properties such as event
modifier keys and event canvas location.
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.
- Version:
- 1.0
- Author:
- Jesse Grosjean
-
Constructor Summary
ConstructorsConstructorDescriptionPInputEvent(PInputManager inputManager, InputEvent event) Create an event with the given inputManager and based on the given swing event. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the mouse button value of the underlying mouse event.Return the bottom most camera that is currently painting.Return the delta between the last and current mouse position in PCanvas coordinates.Return the mouse position in PCanvas coordinates.intReturns the click count of the mouse event.Get the canvas associated with the top camera.getDelta()Return the delta between the last and current mouse positions transformed through the view transform of the bottom camera.getDeltaRelativeTo(PNode nodeOnPath) Return the delta between the last and current mouse positions relative to a given node on the pick path.Return the input manager that dispatched this event.charReturns the character associated with a key event.intReturns the key code associated with a key event.intReturns the location on the keyboard from which the key stroke originated.intReturns the modifiers provided for the input event by swing.intReturns the extended modifiers provided for the input event by swing.getPath()Return the PPickPath associated with this input event.Return the bottom node on the current pickpath, that is the picked node furthest from the root node.Return the mouse position transformed through the view transform of the bottom camera.getPositionRelativeTo(PNode nodeOnPath) Return the mouse position relative to a given node on the pick path.Returns the underlying swing event that this PInputEvent is wrapping.Return the topmost camera this is painting.intReturns the current value of the wheel rotation on Mouse Wheel Rotation events.longgetWhen()Returns the time at which the event was emitted.booleanReturns whether the key event involves the action key.booleanReturns whether the alt key is currently down.booleanReturns whether the control key is currently down.booleanReturns whether the underlying event is a Focus Event.booleanReturn true if another event handler has already handled this event.booleanReturns whether the underlying event is a KeyEvent.booleanReturns whether the mouse event involves the left mouse button.booleanReturns whether the meta key is currently down.booleanReturns whether the mouse event involves the middle mouse button.booleanReturns whether the underlying event is a mouse entered or exited event.booleanReturns whether the underlying event is a MouseEvent.booleanReturns whether the underlying event is a Mouse Wheel Event.booleanReturns whether or not this event is a popup menu trigger event for the platform.booleanReturns whether the mouse event involves the right mouse button.booleanReturns whether the shift key is currently down.voidRemoves the top most cursor from the cursor stack and sets it as the current cursor.voidpushCursor(Cursor cursor) Changes the cursor to the one provided and stores it on the cursor stack for later retrieval.voidsetHandled(boolean handled) Set that this event has been handled by an event handler.voidSets the PIckPath associated with this mouse event.toString()Returns a string representation of this object for debugging purposes.
-
Constructor Details
-
PInputEvent
Create an event with the given inputManager and based on the given swing event.- Parameters:
inputManager- source of PInputEventevent- underlying swing event
-
-
Method Details
-
pushCursor
Changes the cursor to the one provided and stores it on the cursor stack for later retrieval.- Parameters:
cursor- cursor to push on cursor stack
-
popCursor
public void popCursor()Removes the top most cursor from the cursor stack and sets it as the current cursor. -
getCamera
Return the bottom most camera that is currently painting. If you are using internal cameras this may be different then what is returned by getTopCamera.- Returns:
- the current PickPath's bottom camera.
-
getTopCamera
Return the topmost camera this is painting. This is the camera associated with the PCanvas that requested the current repaint.- Returns:
- topmost camera on the pick path
-
getComponent
Get the canvas associated with the top camera. This is the canvas where the originating swing event came from.- Returns:
- component attached to the top camera of the current pick path
-
getInputManager
Return the input manager that dispatched this event. You can use this input manager to find the current mouse focus, mouse over, and key focus nodes. You can also set a new key focus node.- Returns:
- input manager that dispatched this event
-
getPath
Return the PPickPath associated with this input event.- Returns:
- pick path associated with this event (may be null)
-
setPath
Sets the PIckPath associated with this mouse event.- Parameters:
path- path to associate with this mouse event
-
getPickedNode
Return the bottom node on the current pickpath, that is the picked node furthest from the root node.- Returns:
- the currently picked node of this mouse event
-
getKeyCode
public int getKeyCode()Returns the key code associated with a key event.- Returns:
- key code associated with a key event
-
getKeyChar
public char getKeyChar()Returns the character associated with a key event.- Returns:
- char associated with a key event
-
getKeyLocation
public int getKeyLocation()Returns the location on the keyboard from which the key stroke originated.- Returns:
- location on keyboard from which stroke originated.
-
isActionKey
public boolean isActionKey()Returns whether the key event involves the action key.- Returns:
- true if key involved is the action key
-
getModifiers
public int getModifiers()Returns the modifiers provided for the input event by swing.- Returns:
- modifier flags for the input event
-
getModifiersEx
public int getModifiersEx()Returns the extended modifiers provided for the input event by swing.- Returns:
- extended modifies of input event
-
getClickCount
public int getClickCount()Returns the click count of the mouse event.- Returns:
- click count of mouse event
-
getWhen
public long getWhen()Returns the time at which the event was emitted.- Returns:
- time at which the vent was emitted
-
isAltDown
public boolean isAltDown()Returns whether the alt key is currently down.- Returns:
- true if alt key is down
-
isControlDown
public boolean isControlDown()Returns whether the control key is currently down.- Returns:
- true if control key is down
-
isMetaDown
public boolean isMetaDown()Returns whether the meta key is currently down.- Returns:
- true if meta key is down
-
isShiftDown
public boolean isShiftDown()Returns whether the shift key is currently down.- Returns:
- true if shift key is down
-
isLeftMouseButton
public boolean isLeftMouseButton()Returns whether the mouse event involves the left mouse button.- Returns:
- true if left mouse button is involved the mouse event
-
isMiddleMouseButton
public boolean isMiddleMouseButton()Returns whether the mouse event involves the middle mouse button.- Returns:
- true if middle mouse button is involved the mouse event
-
isRightMouseButton
public boolean isRightMouseButton()Returns whether the mouse event involves the right mouse button.- Returns:
- true if right mouse button is involved the mouse event
-
isHandled
public boolean isHandled()Return true if another event handler has already handled this event. Event handlers should use this as a hint before handling the event themselves and possibly reject events that have already been handled.- Returns:
- true if event has been marked as handled
-
setHandled
public void setHandled(boolean handled) Set that this event has been handled by an event handler. This is a relaxed for of consuming events. The event will continue to get dispatched to event handlers even after it is marked as handled, but other event handlers that might conflict are expected to ignore events that have already been handled.- Parameters:
handled- whether the event is marked
-
getButton
public int getButton()Returns the mouse button value of the underlying mouse event.- Returns:
- button value of underlying mouse event
-
getWheelRotation
public int getWheelRotation()Returns the current value of the wheel rotation on Mouse Wheel Rotation events.- Returns:
- wheel rotation value
-
getSourceSwingEvent
Returns the underlying swing event that this PInputEvent is wrapping.- Returns:
- underlying swing event
-
isKeyEvent
public boolean isKeyEvent()Returns whether the underlying event is a KeyEvent.- Returns:
- true if is key event
-
isMouseEvent
public boolean isMouseEvent()Returns whether the underlying event is a MouseEvent.- Returns:
- true if is mouse event
-
isMouseWheelEvent
public boolean isMouseWheelEvent()Returns whether the underlying event is a Mouse Wheel Event.- Returns:
- true if is a mouse wheel event
-
isFocusEvent
public boolean isFocusEvent()Returns whether the underlying event is a Focus Event.- Returns:
- true if is focus event
-
isMouseEnteredOrMouseExited
public boolean isMouseEnteredOrMouseExited()Returns whether the underlying event is a mouse entered or exited event.- Returns:
- true if is a mouse entered or exited event
-
isPopupTrigger
public boolean isPopupTrigger()Returns whether or not this event is a popup menu trigger event for the platform. Must not be called if this event isn't a mouse event.Note: Popup menus are triggered differently on different systems. Therefore,
isPopupTriggershould be checked in bothmousePressedandmouseReleasedfor proper cross-platform functionality.- Returns:
- boolean, true if this event triggers a popup menu for this platform
-
getCanvasPosition
Return the mouse position in PCanvas coordinates.- Returns:
- mouse position in PCanvas coordinates
-
getCanvasDelta
Return the delta between the last and current mouse position in PCanvas coordinates.- Returns:
- delta between last and current mouse position as measured by the PCanvas
-
getPositionRelativeTo
Return the mouse position relative to a given node on the pick path.- Parameters:
nodeOnPath- node on the current PPickPath- Returns:
- mouse position relative to the provided node on pick path
-
getDeltaRelativeTo
Return the delta between the last and current mouse positions relative to a given node on the pick path.- Parameters:
nodeOnPath- node from which to measure- Returns:
- delta between current mouse position and a given node on the pick path
-
getPosition
Return the mouse position transformed through the view transform of the bottom camera.- Returns:
- mouse position as measured by the bottom camera
-
getDelta
Return the delta between the last and current mouse positions transformed through the view transform of the bottom camera.- Returns:
- delta between last and current mouse position as measured by the bottom camera
-
toString
Returns a string representation of this object for debugging purposes.
-