Class MouseDragEvent
- java.util.EventObject
-
- javafx.event.Event
-
- javafx.scene.input.InputEvent
-
- javafx.scene.input.MouseEvent
-
- javafx.scene.input.MouseDragEvent
All Implemented Interfaces:
public final class MouseDragEvent extends MouseEvent
MouseEvent. Full press-drag-release gesture can be started by calling startFullDrag() (on a node or scene) inside of a DRAG_DETECTED event handler. This call activates delivering of MouseDragEvents to the nodes that are under cursor during the dragging gesture.
When you drag a node, it's still under cursor, so it is considered being a potential gesture target during the whole gesture. If you need to drag a node to a different node and let the other node know about it, you need to ensure that the nodes under the dragged node are picked as the potential gesture targets. You can achieve this by calling setMouseTransparent(true) on the dragged node in a MOUSE_PRESSED handler and returning it back to false in a MOUSE_RELEASED handler. This way the nodes under the dragged node will receive the MouseDragEvents, while all the MouseEvents will still be delivered to the (currently mouse transparent) gesture source.
The entered/exited events behave similarly to mouse entered/exited events, please see MouseEvent overview.
Since:
JavaFX 2.1
See Also:
-
Field Summary
Fields Modifier and Type Field and Description static EventType<MouseDragEvent>ANYCommon supertype for all mouse event types.static EventType<MouseDragEvent>MOUSE_DRAG_ENTEREDThis event occurs when the gesture enters a node.static EventType<MouseDragEvent>MOUSE_DRAG_ENTERED_TARGETThis event occurs when the gesture enters a node.static EventType<MouseDragEvent>MOUSE_DRAG_EXITEDThis event occurs when the gesture exits a node.static EventType<MouseDragEvent>MOUSE_DRAG_EXITED_TARGETThis event occurs when the gesture exits a node.static EventType<MouseDragEvent>MOUSE_DRAG_OVERThis event occurs when the gesture progresses within this node.static EventType<MouseDragEvent>MOUSE_DRAG_RELEASEDThis event occurs when the gesture ends (by releasing mouse button) on this node.-
Fields inherited from class javafx.scene.input.MouseEvent
DRAG_DETECTED, MOUSE_CLICKED, MOUSE_DRAGGED, MOUSE_ENTERED, MOUSE_ENTERED_TARGET, MOUSE_EXITED, MOUSE_EXITED_TARGET, MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED
-
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 MouseDragEvent(EventType<MouseDragEvent> eventType, double x, double y, double screenX, double screenY, MouseButton button, int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, PickResult pickResult, Object gestureSource)Constructs new MouseDragEvent event with null source and target.MouseDragEvent(Object source, EventTarget target, EventType<MouseDragEvent> eventType, double x, double y, double screenX, double screenY, MouseButton button, int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, PickResult pickResult, Object gestureSource)Constructs new MouseDragEvent event.
-
Method Summary
All MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description MouseDragEventcopyFor(Object newSource, EventTarget newTarget)Copies this event for a different source and target.MouseDragEventcopyFor(Object newSource, EventTarget newTarget, EventType<? extends MouseEvent> type)Creates a copy of the given event with the given fields substituted.EventType<MouseDragEvent>getEventType()Gets the event type of this event.ObjectgetGestureSource()Returns the source object of the ongoing gesture.StringtoString()Returns a string representation of thisMouseDragEventobject.-
Methods inherited from class javafx.scene.input.MouseEvent
copyForMouseDragEvent, getButton, getClickCount, getPickResult, getSceneX, getSceneY, getScreenX, getScreenY, getX, getY, getZ, isAltDown, isControlDown, isDragDetect, isMetaDown, isMiddleButtonDown, isPopupTrigger, isPrimaryButtonDown, isSecondaryButtonDown, isShiftDown, isShortcutDown, isStillSincePress, isSynthesized, setDragDetect
-
Methods inherited from class java.util.EventObject
getSource
-
-
Field Detail
-
ANY
public static final EventType<MouseDragEvent> ANY
Common supertype for all mouse event types.
-
MOUSE_DRAG_OVER
public static final EventType<MouseDragEvent> MOUSE_DRAG_OVER
This event occurs when the gesture progresses within this node.
-
MOUSE_DRAG_RELEASED
public static final EventType<MouseDragEvent> MOUSE_DRAG_RELEASED
This event occurs when the gesture ends (by releasing mouse button) on this node.
-
MOUSE_DRAG_ENTERED_TARGET
public static final EventType<MouseDragEvent> MOUSE_DRAG_ENTERED_TARGET
This event occurs when the gesture enters a node. It's the bubbling variant, which is delivered also to all parents of the entered node (unless it was consumed). When notifications about mouse entering some of node's children are not desired,MOUSE_DRAG_ENTEREDevent handler should be used.
-
MOUSE_DRAG_ENTERED
public static final EventType<MouseDragEvent> MOUSE_DRAG_ENTERED
This event occurs when the gesture enters a node. This event type is delivered only to the entered node, if parents want to filter it or get the bubbling event, they need to useMOUSE_DRAG_ENTERED_TARGET.
-
MOUSE_DRAG_EXITED_TARGET
public static final EventType<MouseDragEvent> MOUSE_DRAG_EXITED_TARGET
This event occurs when the gesture exits a node. It's the bubbling variant, which is delivered also to all parents of the exited node (unless it was consumed). When notifications about mouse exiting some of node's children are not desired,MOUSE_DRAG_EXITEDevent handler should be used.
-
MOUSE_DRAG_EXITED
public static final EventType<MouseDragEvent> MOUSE_DRAG_EXITED
This event occurs when the gesture exits a node. This event type is delivered only to the exited node, if parents want to filter it or get the bubbling event, they need to useMOUSE_DRAG_EXITED_TARGET.
-
-
Constructor Detail
-
MouseDragEvent
public MouseDragEvent(Object source, EventTarget target, EventType<MouseDragEvent> eventType, double x, double y, double screenX, double screenY, MouseButton button, int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, PickResult pickResult, Object gestureSource)Constructs new MouseDragEvent event.Parameters:
source- the source of the event. Can be null.Since:
JavaFX 8.0
-
MouseDragEvent
public MouseDragEvent(EventType<MouseDragEvent> eventType, double x, double y, double screenX, double screenY, MouseButton button, int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, PickResult pickResult, Object gestureSource)Constructs new MouseDragEvent event with null source and target.Parameters:
eventType- The type of the event.Since:
JavaFX 8.0
-
-
Method Detail
-
getGestureSource
public Object getGestureSource()
Returns the source object of the ongoing gesture. Gesture source is the object that started the full press-drag-release gesture (bystartFullDragmethod being called on it).Returns:
The source object of the gesture.
-
toString
public String toString()
Returns a string representation of thisMouseDragEventobject.Overrides:
toStringin classMouseEventReturns:
a string representation of this
MouseDragEventobject.
-
copyFor
public MouseDragEvent copyFor(Object newSource, EventTarget newTarget)Description copied from class:MouseEventCopies this event for a different source and target. In most cases you don't need to use this method, it's called automatically when you fire the event.Overrides:
copyForin classMouseEventParameters:
newSource- New event sourceReturns:
copy of this event for a different source and target
-
copyFor
public MouseDragEvent copyFor(Object newSource, EventTarget newTarget, EventType<? extends MouseEvent> type)Description copied from class:MouseEventCreates a copy of the given event with the given fields substituted.Overrides:
copyForin classMouseEventReturns:
the event copy with the fields substituted
-
getEventType
public EventType<MouseDragEvent> 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 classMouseEventReturns:
the event type
-
© 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.