Top Description Fields Constructors Methods
javafx.scene.input

public Class ContextMenuEvent

extends InputEvent
Class Inheritance
Imports
com.sun.javafx.scene.input.InputEventUtils, java.io.IOException, javafx.beans.NamedArg, javafx.event.EventTarget, .EventType, javafx.geometry.Point3D

When the user requests a context menu, this event occurs. Context menus can be triggered by the mouse or the keyboard. The exact sequence of mouse or keyboard events that is used to request a menu is platform specific. For example, on Windows, Shift+F10 requests a context menu.

The event coordinates contain default position for the context menu. For mouse-triggered events it is the position of the mouse cursor, for keyboard-triggered events it is a point inside of bounds of current focus owner (which is the event's target).

Since
JavaFX 2.1

Field Summary

Modifier and TypeField and Description
public static final EventType<ContextMenuEvent>
ANY

Hides javafx.scene.input.InputEvent.ANY.

Common supertype for all context menu event types.
public static final EventType<ContextMenuEvent>
CONTEXT_MENU_REQUESTED

This event occurs when a context menu is requested.

private final boolean
keyboardTrigger

The boolean that indicates the event was triggered by a keyboard gesture.

private PickResult
pickResult

Information about the pick if the picked Node is a Shape3D node and its pickOnBounds is false.

private final double
sceneX

Horizontal x position of the event relative to the origin of the Scene that contains the ContextMenuEvent's node.

private final double
sceneY

Vertical y position of the event relative to the origin of the Scene that contains the ContextMenuEvent's node.

private final double
screenX

Absolute horizontal x position of the event.

private final double
screenY

Absolute vertical y position of the event.

private static final long
private transient double
x

Horizontal x position of the event relative to the origin of the ContextMenuEvent's node.

private transient double
y

Vertical y position of the event relative to the origin of the ContextMenuEvent's node.

private transient double
z

Depth z position of the event relative to the origin of the MouseEvent's node.

Constructor Summary

AccessConstructor and Description
public
ContextMenuEvent(Object
the source of the event. Can be null.
source
,
EventTarget
the target of the event. Can be null.
target
,
EventType<ContextMenuEvent>
The type of the event.
eventType
,
double
The x with respect to the scene
x
,
double
The y with respect to the scene
y
,
double
The x coordinate relative to screen.
screenX
,
double
The y coordinate relative to screen.
screenY
,
boolean
true if this event was triggered by keyboard.
keyboardTrigger
,
PickResult
pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates and the target
pickResult
)

Constructs new ContextMenu event.

public
ContextMenuEvent(EventType<ContextMenuEvent>
The type of the event.
eventType
,
double
The x with respect to the scene.
x
,
double
The y with respect to the scene.
y
,
double
The x coordinate relative to screen.
screenX
,
double
The y coordinate relative to screen.
screenY
,
boolean
true if this event was triggered by keyboard.
keyboardTrigger
,
PickResult
pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates
pickResult
)

Constructs new ContextMenu event with empty source and target.

Method Summary

Modifier and TypeMethod and Description
public ContextMenuEvent
copyFor(Object
the new source of the copied event
newSource
,
EventTarget
the new target of the copied event
newTarget
)

Overrides javafx.event.Event.copyFor.

Creates and returns a copy of this event with the specified event source and target.

public EventType<ContextMenuEvent>
getEventType()

Overrides javafx.scene.input.InputEvent.getEventType.

Gets the event type of this event.

public final PickResult

Returns:

new PickResult object that contains information about the pick
getPickResult
()

Returns information about the pick.

public final double

Returns:

horizontal position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source
getSceneX
()

Returns horizontal position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source.

public final double

Returns:

vertical position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source
getSceneY
()

Returns vertical position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source.

public final double

Returns:

absolute horizontal position of the event
getScreenX
()

Returns absolute horizontal position of the event.

public final double

Returns:

absolute vertical position of the event
getScreenY
()

Returns absolute vertical position of the event.

public final double

Returns:

horizontal position of the event relative to the origin of the ContextMenuEvent's source.
getX
()

Horizontal position of the event relative to the origin of the ContextMenuEvent's source.

public final double

Returns:

vertical position of the event relative to the origin of the ContextMenuEvent's source.
getY
()

Vertical position of the event relative to the origin of the ContextMenuEvent's source.

public final double

Returns:

depth position of the event relative to the origin of the MouseEvent's source.
getZ
()

Depth position of the event relative to the origin of the MouseEvent's source.

public boolean

Returns:

true if the event was caused by the keyboard
isKeyboardTrigger
()

Determines whether this event originated from the keyboard.

private void
private void
recomputeCoordinatesToSource(ContextMenuEvent
Event whose coordinates are to be filled
newEvent
,
Object
Source object to compute coordinates for
newSource
)

Fills the given event by this event's coordinates recomputed to the given source object

public String

Returns:

a string representation of this ContextMenuEvent object.
toString
()

Overrides java.util.EventObject.toString.

Returns a string representation of this ContextMenuEvent object.

Field Detail

ANYback to summary
public static final EventType<ContextMenuEvent> ANY

Hides javafx.scene.input.InputEvent.ANY.

Common supertype for all context menu event types.

Since
JavaFX 8.0
CONTEXT_MENU_REQUESTEDback to summary
public static final EventType<ContextMenuEvent> CONTEXT_MENU_REQUESTED

This event occurs when a context menu is requested.

keyboardTriggerback to summary
private final boolean keyboardTrigger

The boolean that indicates the event was triggered by a keyboard gesture.

pickResultback to summary
private PickResult pickResult

Information about the pick if the picked Node is a Shape3D node and its pickOnBounds is false.

sceneXback to summary
private final double sceneX

Horizontal x position of the event relative to the origin of the Scene that contains the ContextMenuEvent's node. If the node is not in a Scene, then the value is relative to the boundsInParent of the root-most parent of the ContextMenuEvent's node.

sceneYback to summary
private final double sceneY

Vertical y position of the event relative to the origin of the Scene that contains the ContextMenuEvent's node. If the node is not in a Scene, then the value is relative to the boundsInParent of the root-most parent of the ContextMenuEvent's node.

screenXback to summary
private final double screenX

Absolute horizontal x position of the event.

screenYback to summary
private final double screenY

Absolute vertical y position of the event.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javafx.scene.input.InputEvent.serialVersionUID.

xback to summary
private transient double x

Horizontal x position of the event relative to the origin of the ContextMenuEvent's node.

yback to summary
private transient double y

Vertical y position of the event relative to the origin of the ContextMenuEvent's node.

zback to summary
private transient double z

Depth z position of the event relative to the origin of the MouseEvent's node.

Constructor Detail

ContextMenuEventback to summary
public ContextMenuEvent(Object source, EventTarget target, EventType<ContextMenuEvent> eventType, double x, double y, double screenX, double screenY, boolean keyboardTrigger, PickResult pickResult)

Constructs new ContextMenu event.

Parameters
source:Object

the source of the event. Can be null.

target:EventTarget

the target of the event. Can be null.

eventType:EventType<ContextMenuEvent>

The type of the event.

x:double

The x with respect to the scene

y:double

The y with respect to the scene

screenX:double

The x coordinate relative to screen.

screenY:double

The y coordinate relative to screen.

keyboardTrigger:boolean

true if this event was triggered by keyboard.

pickResult:PickResult

pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates and the target

Since
JavaFX 8.0
ContextMenuEventback to summary
public ContextMenuEvent(EventType<ContextMenuEvent> eventType, double x, double y, double screenX, double screenY, boolean keyboardTrigger, PickResult pickResult)

Constructs new ContextMenu event with empty source and target.

Parameters
eventType:EventType<ContextMenuEvent>

The type of the event.

x:double

The x with respect to the scene.

y:double

The y with respect to the scene.

screenX:double

The x coordinate relative to screen.

screenY:double

The y coordinate relative to screen.

keyboardTrigger:boolean

true if this event was triggered by keyboard.

pickResult:PickResult

pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates

Since
JavaFX 8.0

Method Detail

copyForback to summary
public ContextMenuEvent copyFor(Object newSource, EventTarget newTarget)

Overrides javafx.event.Event.copyFor.

Doc from javafx.event.Event.copyFor.

Creates and returns a copy of this event with the specified event source and target. If the source or target is set to null, it is replaced by the NULL_SOURCE_TARGET value.

Parameters
newSource:Object

the new source of the copied event

newTarget:EventTarget

the new target of the copied event

Returns:ContextMenuEvent

the event copy with the new source and target

Annotations
@Override
getEventTypeback to summary
public EventType<ContextMenuEvent> getEventType()

Overrides javafx.scene.input.InputEvent.getEventType.

Doc from javafx.event.Event.getEventType.

Gets the event type of this event. Objects of the same Event class can have different event types. These event types further specify what kind of event occurred.

Returns:EventType<ContextMenuEvent>

the event type

Annotations
@Override
getPickResultback to summary
public final PickResult getPickResult()

Returns information about the pick.

Returns:PickResult

new PickResult object that contains information about the pick

Since
JavaFX 8.0
getSceneXback to summary
public final double getSceneX()

Returns horizontal position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source. If the node is not in a Scene, then the value is relative to the boundsInParent of the root-most parent of the ContextMenuEvent's node. For more information about this event's coordinate semantics please see the general description of ContextMenuEvent. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.

Returns:double

horizontal position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source

getSceneYback to summary
public final double getSceneY()

Returns vertical position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source. If the node is not in a Scene, then the value is relative to the boundsInParent of the root-most parent of the ContextMenuEvent's node. For more information about this event's coordinate semantics please see the general description of ContextMenuEvent. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.

Returns:double

vertical position of the event relative to the origin of the Scene that contains the ContextMenuEvent's source

getScreenXback to summary
public final double getScreenX()

Returns absolute horizontal position of the event. For more information about this event's coordinate semantics please see the general description of ContextMenuEvent.

Returns:double

absolute horizontal position of the event

getScreenYback to summary
public final double getScreenY()

Returns absolute vertical position of the event. For more information about this event's coordinate semantics please see the general description of ContextMenuEvent.

Returns:double

absolute vertical position of the event

getXback to summary
public final double getX()

Horizontal position of the event relative to the origin of the ContextMenuEvent's source. For more information about this event's coordinate semantics please see the general description of ContextMenuEvent.

Returns:double

horizontal position of the event relative to the origin of the ContextMenuEvent's source.

getYback to summary
public final double getY()

Vertical position of the event relative to the origin of the ContextMenuEvent's source. For more information about this event's coordinate semantics please see the general description of ContextMenuEvent.

Returns:double

vertical position of the event relative to the origin of the ContextMenuEvent's source.

getZback to summary
public final double getZ()

Depth position of the event relative to the origin of the MouseEvent's source.

Returns:double

depth position of the event relative to the origin of the MouseEvent's source.

Since
JavaFX 8.0
isKeyboardTriggerback to summary
public boolean isKeyboardTrigger()

Determines whether this event originated from the keyboard.

Returns:boolean

true if the event was caused by the keyboard

readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Hides javafx.event.Event.readObject.

Annotations
@SuppressWarnings:doclint:missing
recomputeCoordinatesToSourceback to summary
private void recomputeCoordinatesToSource(ContextMenuEvent newEvent, Object newSource)

Fills the given event by this event's coordinates recomputed to the given source object

Parameters
newEvent:ContextMenuEvent

Event whose coordinates are to be filled

newSource:Object

Source object to compute coordinates for

toStringback to summary
public String toString()

Overrides java.util.EventObject.toString.

Returns a string representation of this ContextMenuEvent object.

Returns:String

a string representation of this ContextMenuEvent object.

Annotations
@Override