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

DragAndDrop: custom data issue on MacOS

    Details

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

      Mac OSX 10.6.4/JDK6/b08

      Description

      DragOver/DragDropped events are not received after putting custom data into dragboard 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.COPY);
                      System.out.println("Transfer modes: " + db.getTransferModes());
                      ClipboardContent cont = new ClipboardContent();
                      cont.put(new DataFormat("dndwithcontrols.custom.bytes"), new byte[] {1, 2, 3, 4});
                      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:
                gziemski Gerard Ziemski
                Reporter:
                ogb Oleg Barbashov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: