Class ContextMenuEvent
- java.util.EventObject
-
- javafx.event.Event
-
- javafx.scene.input.InputEvent
-
- javafx.scene.input.ContextMenuEvent
All Implemented Interfaces:
public class ContextMenuEvent extends InputEvent
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
See Also:
-
Field Summary
Fields Modifier and Type Field and Description static EventType<ContextMenuEvent>ANYCommon supertype for all context menu event types.static EventType<ContextMenuEvent>CONTEXT_MENU_REQUESTEDThis event occurs when a context menu is requested.-
Fields inherited from class javafx.event.Event
consumed, eventType, NULL_SOURCE_TARGET, target
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor and Description 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.ContextMenuEvent(Object source, EventTarget target, EventType<ContextMenuEvent> eventType, double x, double y, double screenX, double screenY, boolean keyboardTrigger, PickResult pickResult)Constructs new ContextMenu event.
-
Method Summary
All MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description ContextMenuEventcopyFor(Object newSource, EventTarget newTarget)Creates and returns a copy of this event with the specified event source and target.EventType<ContextMenuEvent>getEventType()Gets the event type of this event.PickResultgetPickResult()Returns information about the pick.doublegetSceneX()Returns horizontal position of the event relative to the origin of theScenethat contains the ContextMenuEvent's source.doublegetSceneY()Returns vertical position of the event relative to the origin of theScenethat contains the ContextMenuEvent's source.doublegetScreenX()Returns absolute horizontal position of the event.doublegetScreenY()Returns absolute vertical position of the event.doublegetX()Horizontal position of the event relative to the origin of the ContextMenuEvent's source.doublegetY()Vertical position of the event relative to the origin of the ContextMenuEvent's source.doublegetZ()Depth position of the event relative to the origin of the MouseEvent's source.booleanisKeyboardTrigger()Determines whether this event originated from the keyboard.StringtoString()Returns a string representation of thisContextMenuEventobject.-
Methods inherited from class java.util.EventObject
getSource
-
-
Field Detail
-
CONTEXT_MENU_REQUESTED
public static final EventType<ContextMenuEvent> CONTEXT_MENU_REQUESTED
This event occurs when a context menu is requested.
-
ANY
public static final EventType<ContextMenuEvent> ANY
Common supertype for all context menu event types.Since:
JavaFX 8.0
-
-
Constructor Detail
-
ContextMenuEvent
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- the source of the event. Can be null.Since:
JavaFX 8.0
-
ContextMenuEvent
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- The type of the event.Since:
JavaFX 8.0
-
-
Method Detail
-
copyFor
public ContextMenuEvent copyFor(Object newSource, EventTarget newTarget)Description copied from class:EventCreates and returns a copy of this event with the specified event source and target. If the source or target is set tonull, it is replaced by theNULL_SOURCE_TARGETvalue.
-
getEventType
public EventType<ContextMenuEvent> getEventType()
Description copied from class:EventGets the event type of this event. Objects of the sameEventclass can have different event types. These event types further specify what kind of event occurred.Overrides:
getEventTypein classInputEventReturns:
the event type
-
isKeyboardTrigger
public boolean isKeyboardTrigger()
Determines whether this event originated from the keyboard.Returns:
true if the event was caused by the keyboard
-
getX
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 ofContextMenuEvent.Returns:
horizontal position of the event relative to the origin of the ContextMenuEvent's source.
-
getY
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 ofContextMenuEvent.Returns:
vertical position of the event relative to the origin of the ContextMenuEvent's source.
-
getZ
public final double getZ()
Depth position of the event relative to the origin of the MouseEvent's source.Returns:
depth position of the event relative to the origin of the MouseEvent's source.
Since:
JavaFX 8.0
-
getScreenX
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 ofContextMenuEvent.Returns:
absolute horizontal position of the event
-
getScreenY
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 ofContextMenuEvent.Returns:
absolute vertical position of the event
-
getSceneX
public final double getSceneX()
Returns horizontal position of the event relative to the origin of theScenethat contains the ContextMenuEvent's source. If the node is not in aScene, 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 ofContextMenuEvent. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.Returns:
horizontal position of the event relative to the origin of the
Scenethat contains the ContextMenuEvent's source
-
getSceneY
public final double getSceneY()
Returns vertical position of the event relative to the origin of theScenethat contains the ContextMenuEvent's source. If the node is not in aScene, 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 ofContextMenuEvent. Note that in 3D scene, this represents the flat coordinates after applying the projection transformations.Returns:
vertical position of the event relative to the origin of the
Scenethat contains the ContextMenuEvent's source
-
getPickResult
public final PickResult getPickResult()
Returns information about the pick.Returns:
new PickResult object that contains information about the pick
Since:
JavaFX 8.0
-
toString
public String toString()
Returns a string representation of thisContextMenuEventobject.Overrides:
toStringin classEventObjectReturns:
a string representation of this
ContextMenuEventobject.
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.