Reputation: 564
I think this should be really easy with JavaFX - so I must be missing the point somewhere. I have a simple drag-and-drop from a toolbar onto an AnchorPane which works fine, however I'm trying to find out exactly where the drop occurs to find out where to insert the new item within a group of Nodes already there. The event object DragEvent tells you the target object but not where it was dropped relative to the target ( only relative to the source ). I tried just listening to all mouse released events on the target but that isn't triggered for a drag onto an object. Anyone know how this should be done?
Mike Watts
Upvotes: 1
Views: 133
Reputation: 6574
You can either use the getSceneX/Y
methods to obtain absolute coordinates of the location of the drop or install a listener on the AnchorPane which listens to DRAG_OVER DragEvents. The last position of the DRAG_OVER event that occured before it was dropped is the position where it was dropped.
Upvotes: 1