Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8128384

Mac: DragAndDrop: file transfer issue on MacOS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0.2
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Environment:

      Mac OSX 10.6.4/JDK6/b08

      Description

      DragOver/DragDropped events are not received after putting file data into dragboard on Mac. Sample to reproduce:

      public class Main extends Application {

          Pane group;

          public static void main(String[] args) {
              launch(args);
          }

          private Parent getContent() {
              VBox list = new VBox(10);

              final Button btn = new Button("Button");

              list.getChildren().add(btn);

              btn.setOnDragDetected(new EventHandler<MouseEvent>() {

                  @Override
                  public void handle(MouseEvent t) {
                      System.out.println("OnDragDetected");

                      Dragboard db = btn.startDragAndDrop(TransferMode.MOVE);
                      System.out.println("Transfer modes: " + db.getTransferModes());
                      ClipboardContent cont = new ClipboardContent();
                      List<File> fl = new LinkedList<File>();
                      fl.add(new File("tmp.txt"));
                      cont.putFiles(fl);
                      db.setContent(cont);
                      t.consume();
                  }
              });

              btn.setOnDragOver(new EventHandler<DragEvent>() {
                  @Override
                  public void handle(DragEvent t) {
                      System.out.println("OnDragOver");
                      t.acceptTransferModes(TransferMode.ANY);
                  }
              });

              btn.setOnDragDropped(new EventHandler<DragEvent>() {
                  @Override
                  public void handle(DragEvent t) {
                      System.out.println("OnDragDropped");
                      t.setDropCompleted(true);
                  }
              });


              return list;
          }

          public void start(Stage stage) {
              stage.setX(100);
              stage.setY(100);
              stage.setWidth(300);
              stage.setHeight(300);
              Scene scene = new Scene(group = new VBox());
              group.getChildren().add(getContent());
              group.getChildren().add(getContent());
              stage.setScene(scene);
              stage.show();

          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              morris Morris Meyer (Inactive)
              Reporter:
              ogb Oleg Barbashov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: