DnD Move does not work on OS-X
Tom Schindl
tom.schindl at bestsolution.at
Thu Jan 9 14:48:40 UTC 2020
Hi,
I must be doing something completely wrong or there is a major bug in
JavaFX-DnD from Java-8 upwards to JavaFX-14-ea.
If you run the attached application on OS-X the and press the CMD-key
while dragging you get null for the getTransferMode() inside DragOver
and you don't get a DragDropped and null on the DragDone.
I tracked that back to View#notifyDragOver() where one gets 0 from the
native side. So am I missing something in my code?
I also tried with
https://docs.oracle.com/javafx/2/drag_drop/jfxpub-drag_drop.htm and it
does not work either.
So I guess it's a major bug in openjfx but before filing a jira-ticket I
wanted to make extra sure it's not a stupid mistake, my german operating
system, ...
Tom
--
Tom Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Salurnerstrasse 15. A-6020 Innsbruck
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck
-------------- next part --------------
package bla;
import java.util.UUID;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class SampleApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
HBox b = new HBox(50);
Rectangle sourceR = new Rectangle(300, 300);
sourceR.setOnDragDetected( evt -> {
Dragboard dragboard = sourceR.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
content.putString(UUID.randomUUID().toString());
dragboard.setContent(content);
evt.consume();
});
sourceR.setOnDragDone( evt -> System.err.println("Done: " + evt.getTransferMode()));
sourceR.setFill(Color.RED);
Rectangle targetR = new Rectangle(300, 300);
targetR.setOnDragOver( evt -> {
evt.acceptTransferModes(TransferMode.ANY);
System.err.println(evt.getTransferMode());
evt.consume();
});
targetR.setOnDragDropped( evt -> {
System.err.println("Completed: " + evt.getTransferMode());
evt.setDropCompleted(true);
evt.consume();
});
targetR.setFill(Color.BLUE);
b.getChildren().setAll(sourceR, targetR);
Scene s = new Scene(new VBox(b), 800, 600);
primaryStage.setScene(s);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
More information about the openjfx-dev
mailing list