Reputation: 55
I am trying to create a drag and drop solution between my treetableview and some rectangles in my interface. For now I am able to drag a row from my treeTableView and when I drag it over my rectangle, then the color of the rectangle change. But now I would like to be notified when the drag is not over anymore, so that i can change back the color on my rectangle. But I am not able to see an event doing this.
Upvotes: 1
Views: 533
Reputation: 21829
For the drag target you have four different properties:
onDragEnteredProperty
: called when drag gesture enters this Node
onDragOverProperty
: called when drag gesture progresses within this Node
onDragExitedProperty
: called when drag gesture exits this Node
onDragDroppedProperty
: called when the mouse button is released on this Node
during drag and drop gesture
You can use this properties to define a behaviour of the target Node
, like:
Rectangle rect = new Rectangle();
rect.setOnDragEntered(value -> {
// Set the drag-over color here
});
rect.setOnDragExited(value -> {
// Reset the original color here
});
rect.setOnDragDropped(value -> {
// Reset the original color here
});
Upvotes: 1