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

Mac: DragAndDrop: TransferMode.MOVE issue on Mac

    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 setting TransferMode.MOVE on Mac. Sample to reproduce:

      import javafx.application.Application;
      import javafx.event.EventHandler;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.input.ClipboardContent;
      import javafx.scene.input.DataFormat;
      import javafx.scene.input.DragEvent;
      import javafx.scene.input.Dragboard;
      import javafx.scene.input.MouseEvent;
      import javafx.scene.input.TransferMode;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      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();
                      //cont.put(new DataFormat("dndwithcontrols.custom.bytes"), new byte[] {1, 2, 3, 4});
                      cont.putString("String");
                      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

          Activity

            People

            Assignee:
            gziemski Gerard Ziemski
            Reporter:
            ogb Oleg Barbashov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: