Reputation: 1124
I am using SceneBuilder to develop a JavaFX application. I have ImageView object and setOnDragDropped is not triggering. I am not getting any errors. For onDragDetected everything is working. I tried these two options: 1) to set it from the SceneBuilder (see the screenshot)
Second way was from the controller code:
@FXML public void sensorDrop(DragEvent event) {
System.out.println("Drooooop!>>");
event.consume();
//TODO More useful code
}
Any thoughts?
Upvotes: 0
Views: 750
Reputation: 1124
To make it complete- in order to register it the setOnDragOver
has to be registered
label.setOnDragOver(new EventHandler <DragEvent>() {
public void handle(DragEvent event) {
event.acceptTransferModes(TransferMode.ANY);
event.consume();
}
});
I took this answer from: JavaFX OnDragDropped Not Registering
Upvotes: 1
Reputation: 209330
The onDragDropped
handler is called when you drop something onto the node with which it is registered, not when you drop that node on something. So you need to register the onDragDropped
handler on the stack pane.
Upvotes: 1