-
Bug
-
Resolution: Fixed
-
P4
-
fx2.1
-
Mac OS X 10.7.2, JavaFX 2.1 beta b05, Java 1.6.0_29
When the following application is run under Mac OS X, DRAG_DROPPED never appears in the output. The output consists only of DRAG_OVER events:
===== DRAG_OVER =====
system mode: null
source modes: []
accepted modes: null
WARNING: unhandled case in mapNsOperationToJavaMask: 0 [on thread "0x0x7fff7adb3960", is main:1]
===== DRAG_OVER =====
system mode: null
source modes: []
accepted modes: null
WARNING: unhandled case in mapNsOperationToJavaMask: 0 [on thread "0x0x7fff7adb3960", is main:1]
etc.
On Windows with the latest JavaFX 2.0.2, the output is as expected:
===== DRAG_OVER =====
system mode: MOVE
source modes: [COPY, MOVE, LINK]
accepted modes: MOVE
===== DRAG_OVER =====
system mode: MOVE
source modes: [COPY, MOVE, LINK]
accepted modes: MOVE
===== DRAG_DROPPED =====
Dropped: [C:\Users\Dean Iverson\Documents\ca\DragDrop2.jar]
The code is as follows:
public class DragDrop1 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Rectangle rect = new Rectangle(100, 100);
rect.setId("dragTarget");
rect.setOnDragOver(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println("===== DRAG_OVER =====");
System.out.println("system mode: "+event.getTransferMode());
Dragboard db = event.getDragboard();
System.out.println("source modes: "+db.getTransferModes());
if (db.hasFiles()) {
event.acceptTransferModes(TransferMode.ANY);
System.out.println("accepted modes: "+event.getAcceptedTransferMode());
}
event.consume();
}
});
rect.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println("===== DRAG_DROPPED =====");
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles()) {
System.out.println("Dropped: " + db.getFiles());
success = true;
}
event.setDropCompleted(success);
event.consume();
}
});
final StackPane root = new StackPane();
root.getChildren().add(rect);
final Scene scene = new Scene(root);
final URL stylesheet = getClass().getResource("media.css");
scene.getStylesheets().add(stylesheet.toString());
primaryStage.setScene(scene);
primaryStage.setTitle("Audio Player 2");
primaryStage.show();
}
}
===== DRAG_OVER =====
system mode: null
source modes: []
accepted modes: null
WARNING: unhandled case in mapNsOperationToJavaMask: 0 [on thread "0x0x7fff7adb3960", is main:1]
===== DRAG_OVER =====
system mode: null
source modes: []
accepted modes: null
WARNING: unhandled case in mapNsOperationToJavaMask: 0 [on thread "0x0x7fff7adb3960", is main:1]
etc.
On Windows with the latest JavaFX 2.0.2, the output is as expected:
===== DRAG_OVER =====
system mode: MOVE
source modes: [COPY, MOVE, LINK]
accepted modes: MOVE
===== DRAG_OVER =====
system mode: MOVE
source modes: [COPY, MOVE, LINK]
accepted modes: MOVE
===== DRAG_DROPPED =====
Dropped: [C:\Users\Dean Iverson\Documents\ca\DragDrop2.jar]
The code is as follows:
public class DragDrop1 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Rectangle rect = new Rectangle(100, 100);
rect.setId("dragTarget");
rect.setOnDragOver(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println("===== DRAG_OVER =====");
System.out.println("system mode: "+event.getTransferMode());
Dragboard db = event.getDragboard();
System.out.println("source modes: "+db.getTransferModes());
if (db.hasFiles()) {
event.acceptTransferModes(TransferMode.ANY);
System.out.println("accepted modes: "+event.getAcceptedTransferMode());
}
event.consume();
}
});
rect.setOnDragDropped(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
System.out.println("===== DRAG_DROPPED =====");
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles()) {
System.out.println("Dropped: " + db.getFiles());
success = true;
}
event.setDropCompleted(success);
event.consume();
}
});
final StackPane root = new StackPane();
root.getChildren().add(rect);
final Scene scene = new Scene(root);
final URL stylesheet = getClass().getResource("media.css");
scene.getStylesheets().add(stylesheet.toString());
primaryStage.setScene(scene);
primaryStage.setTitle("Audio Player 2");
primaryStage.show();
}
}
- relates to
-
JDK-8128384 Mac: DragAndDrop: file transfer issue on MacOS
-
- Closed
-