Top Description Fields Constructors Methods
javafx.scene.input

public final Class MouseDragEvent

extends MouseEvent
Class Inheritance
Imports
javafx.beans.NamedArg, javafx.event.EventTarget, .EventType

Mouse drag events are delivered to potential gesture targets during full press-drag-release gestures. The difference among different gesture types is described at 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

Field Summary

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

Hides javafx.scene.input.MouseEvent.ANY.

Common supertype for all mouse event types.
private final transient Object
public static final EventType<MouseDragEvent>
MOUSE_DRAG_ENTERED

This event occurs when the gesture enters a node.

public static final EventType<MouseDragEvent>
MOUSE_DRAG_ENTERED_TARGET

This event occurs when the gesture enters a node.

public static final EventType<MouseDragEvent>
MOUSE_DRAG_EXITED

This event occurs when the gesture exits a node.

public static final EventType<MouseDragEvent>
MOUSE_DRAG_EXITED_TARGET

This event occurs when the gesture exits a node.

public static final EventType<MouseDragEvent>
MOUSE_DRAG_OVER

This event occurs when the gesture progresses within this node.

public static final EventType<MouseDragEvent>
MOUSE_DRAG_RELEASED

This event occurs when the gesture ends (by releasing mouse button) on this node.

private static final long
Inherited from javafx.scene.input.MouseEvent:
DRAG_DETECTEDMOUSE_CLICKEDMOUSE_DRAGGEDMOUSE_ENTEREDMOUSE_ENTERED_TARGETMOUSE_EXITEDMOUSE_EXITED_TARGETMOUSE_MOVEDMOUSE_PRESSEDMOUSE_RELEASED

Constructor Summary

AccessConstructor and Description
public
MouseDragEvent(Object
the source of the event, which can be null
source
,
EventTarget
the target of the event, which can be null
target
,
EventType<MouseDragEvent>
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
,
MouseButton
the mouse button used
button
,
int
number of click counts
clickCount
,
boolean
true if shift modifier was pressed
shiftDown
,
boolean
true if control modifier was pressed
controlDown
,
boolean
true if alt modifier was pressed
altDown
,
boolean
true if meta modifier was pressed
metaDown
,
boolean
true if primary button was pressed
primaryButtonDown
,
boolean
true if middle button was pressed
middleButtonDown
,
boolean
true if secondary button was pressed
secondaryButtonDown
,
boolean
if this event was synthesized
synthesized
,
boolean
whether this event denotes a popup trigger for current platform
popupTrigger
,
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 target
pickResult
,
Object
source object of the ongoing gesture
gestureSource
)

Constructs new MouseDragEvent event.

public
MouseDragEvent(Object
the source of the event, which can be null
source
,
EventTarget
the target of the event, which can be null
target
,
EventType<MouseDragEvent>
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
,
MouseButton
the mouse button used
button
,
int
number of click counts
clickCount
,
boolean
true if shift modifier was pressed
shiftDown
,
boolean
true if control modifier was pressed
controlDown
,
boolean
true if alt modifier was pressed
altDown
,
boolean
true if meta modifier was pressed
metaDown
,
boolean
true if primary button was pressed
primaryButtonDown
,
boolean
true if middle button was pressed
middleButtonDown
,
boolean
true if secondary button was pressed
secondaryButtonDown
,
boolean
true if back button was pressed
backButtonDown
,
boolean
true if forward button was pressed
forwardButtonDown
,
boolean
if this event was synthesized
synthesized
,
boolean
whether this event denotes a popup trigger for current platform
popupTrigger
,
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 target
pickResult
,
Object
source object of the ongoing gesture
gestureSource
)

Constructs new MouseDragEvent event.

public
MouseDragEvent(EventType<MouseDragEvent>
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
,
MouseButton
the mouse button used
button
,
int
number of click counts
clickCount
,
boolean
true if shift modifier was pressed
shiftDown
,
boolean
true if control modifier was pressed
controlDown
,
boolean
true if alt modifier was pressed
altDown
,
boolean
true if meta modifier was pressed
metaDown
,
boolean
true if primary button was pressed
primaryButtonDown
,
boolean
true if middle button was pressed
middleButtonDown
,
boolean
true if secondary button was pressed
secondaryButtonDown
,
boolean
if this event was synthesized
synthesized
,
boolean
whether this event denotes a popup trigger for current platform
popupTrigger
,
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
,
Object
source object of the ongoing gesture
gestureSource
)

Constructs new MouseDragEvent event with null source and target.

Method Summary

Modifier and TypeMethod and Description
public MouseDragEvent
copyFor(Object
New event source
newSource
,
EventTarget
New event target
newTarget
)

Overrides javafx.scene.input.MouseEvent.copyFor.

Copies this event for a different source and target.

public MouseDragEvent
copyFor(Object
the new source of the copied event
newSource
,
EventTarget
the new target of the copied event
newTarget
,
EventType<? extends MouseEvent>
the new eventType
type
)

Overrides javafx.scene.input.MouseEvent.copyFor.

Creates a copy of the given event with the given fields substituted.

public EventType<MouseDragEvent>
getEventType()

Overrides javafx.scene.input.MouseEvent.getEventType.

Gets the event type of this event.

public Object

Returns:

The source object of the gesture.
getGestureSource
()

Returns the source object of the ongoing gesture.

public String

Returns:

a string representation of this MouseDragEvent object.
toString
()

Overrides javafx.scene.input.MouseEvent.toString.

Returns a string representation of this MouseDragEvent object.

Inherited from javafx.scene.input.MouseEvent:
copyForMouseDragEventgetButtongetClickCountgetPickResultgetSceneXgetSceneYgetScreenXgetScreenYgetXgetYgetZisAltDownisBackButtonDownisControlDownisDragDetectisForwardButtonDownisMetaDownisMiddleButtonDownisPopupTriggerisPrimaryButtonDownisSecondaryButtonDownisShiftDownisShortcutDownisStillSincePressisSynthesizedrecomputeCoordinatesToSourcesetDragDetect

Field Detail

ANYback to summary
public static final EventType<MouseDragEvent> ANY

Hides javafx.scene.input.MouseEvent.ANY.

Common supertype for all mouse event types.

gestureSourceback to summary
private final transient Object gestureSource
MOUSE_DRAG_ENTEREDback to summary
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 use MOUSE_DRAG_ENTERED_TARGET.

See Also
MouseEvent for more information about mouse entered/exited handling which is similar
MOUSE_DRAG_ENTERED_TARGETback to summary
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_ENTERED event handler should be used.

See Also
MouseEvent for more information about mouse entered/exited handling which is similar
MOUSE_DRAG_EXITEDback to summary
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 use MOUSE_DRAG_EXITED_TARGET.

See Also
MouseEvent for more information about mouse entered/exited handling which is similar
MOUSE_DRAG_EXITED_TARGETback to summary
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_EXITED event handler should be used.

See Also
MouseEvent for more information about mouse entered/exited handling which is similar
MOUSE_DRAG_OVERback to summary
public static final EventType<MouseDragEvent> MOUSE_DRAG_OVER

This event occurs when the gesture progresses within this node.

MOUSE_DRAG_RELEASEDback to summary
public static final EventType<MouseDragEvent> MOUSE_DRAG_RELEASED

This event occurs when the gesture ends (by releasing mouse button) on this node.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javafx.scene.input.MouseEvent.serialVersionUID.

Constructor Detail

MouseDragEventback to summary
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. Both isBackButtonDown() and isForwardButtonDown() will return false for this event

Parameters
source:Object

the source of the event, which can be null

target:EventTarget

the target of the event, which can be null

eventType:EventType<MouseDragEvent>

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

button:MouseButton

the mouse button used

clickCount:int

number of click counts

shiftDown:boolean

true if shift modifier was pressed

controlDown:boolean

true if control modifier was pressed

altDown:boolean

true if alt modifier was pressed

metaDown:boolean

true if meta modifier was pressed

primaryButtonDown:boolean

true if primary button was pressed

middleButtonDown:boolean

true if middle button was pressed

secondaryButtonDown:boolean

true if secondary button was pressed

synthesized:boolean

if this event was synthesized

popupTrigger:boolean

whether this event denotes a popup trigger for current platform

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 target

gestureSource:Object

source object of the ongoing gesture

Since
JavaFX 8.0
MouseDragEventback to summary
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 backButtonDown, boolean forwardButtonDown, boolean synthesized, boolean popupTrigger, PickResult pickResult, Object gestureSource)

Constructs new MouseDragEvent event.

Parameters
source:Object

the source of the event, which can be null

target:EventTarget

the target of the event, which can be null

eventType:EventType<MouseDragEvent>

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

button:MouseButton

the mouse button used

clickCount:int

number of click counts

shiftDown:boolean

true if shift modifier was pressed

controlDown:boolean

true if control modifier was pressed

altDown:boolean

true if alt modifier was pressed

metaDown:boolean

true if meta modifier was pressed

primaryButtonDown:boolean

true if primary button was pressed

middleButtonDown:boolean

true if middle button was pressed

secondaryButtonDown:boolean

true if secondary button was pressed

backButtonDown:boolean

true if back button was pressed

forwardButtonDown:boolean

true if forward button was pressed

synthesized:boolean

if this event was synthesized

popupTrigger:boolean

whether this event denotes a popup trigger for current platform

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 target

gestureSource:Object

source object of the ongoing gesture

Since
12
MouseDragEventback to summary
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. Both isBackButtonDown() and isForwardButtonDown() will return false for this event.

Parameters
eventType:EventType<MouseDragEvent>

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

button:MouseButton

the mouse button used

clickCount:int

number of click counts

shiftDown:boolean

true if shift modifier was pressed

controlDown:boolean

true if control modifier was pressed

altDown:boolean

true if alt modifier was pressed

metaDown:boolean

true if meta modifier was pressed

primaryButtonDown:boolean

true if primary button was pressed

middleButtonDown:boolean

true if middle button was pressed

secondaryButtonDown:boolean

true if secondary button was pressed

synthesized:boolean

if this event was synthesized

popupTrigger:boolean

whether this event denotes a popup trigger for current platform

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

gestureSource:Object

source object of the ongoing gesture

Since
JavaFX 8.0

Method Detail

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

Overrides javafx.scene.input.MouseEvent.copyFor.

Doc from javafx.scene.input.MouseEvent.copyFor.

Copies 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.

Parameters
newSource:Object

New event source

newTarget:EventTarget

New event target

Returns:MouseDragEvent

copy of this event for a different source and target

Annotations
@Override
copyForback to summary
public MouseDragEvent copyFor(Object newSource, EventTarget newTarget, EventType<? extends MouseEvent> type)

Overrides javafx.scene.input.MouseEvent.copyFor.

Doc from javafx.scene.input.MouseEvent.copyFor.

Creates a copy of the given event with the given fields substituted.

Parameters
newSource:Object

the new source of the copied event

newTarget:EventTarget

the new target of the copied event

type:EventType<? extends MouseEvent>

the new eventType

Returns:MouseDragEvent

the event copy with the fields substituted

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

Overrides javafx.scene.input.MouseEvent.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<MouseDragEvent>

the event type

Annotations
@Override
getGestureSourceback to summary
public Object getGestureSource()

Returns the source object of the ongoing gesture. Gesture source is the object that started the full press-drag-release gesture (by startFullDrag method being called on it).

Returns:Object

The source object of the gesture.

toStringback to summary
public String toString()

Overrides javafx.scene.input.MouseEvent.toString.

Returns a string representation of this MouseDragEvent object.

Returns:String

a string representation of this MouseDragEvent object.

Annotations
@Override