2
votes

In my JavaFX application I need to detect when the user canceled a drag action (like right clicking while dragging or pressing ESC button while dragging). I tried to listen on every DragEvent type on my main window, like DRAG_EXITED_TARGET or DRAG_EXITED but those are fired even if the cursor moves to another Node... I'm unable to narrow it to the single event of canceling the drag action. I read that event.getGestureTarget() == null could mean that the user canceled the action, but it's also null when it leaves to another Node.

1

1 Answers

0
votes

I managed to get this working for me by adding a PropertyChangeListener to a window's focusedProperty. When the user cancels the drag action, my window is losing the focus so this works for me.