Detecting successful file drops on macOS
Martin Fox
martin at martinfox.com
Sun Feb 11 00:31:06 UTC 2024
Hi Christopher,
This is a bug in the Mac platform code. I’ve created a JBS issue, see https://bugs.openjdk.org/browse/JDK-8325591. Unfortunately I haven’t found a work-around for it.
Martin
> On Feb 9, 2024, at 9:17 PM, Christopher Schnick <crschnick at xpipe.io> wrote:
>
> Hello,
> I'm using macOS Sonoma 14.3 aarch64 and I'm trying to recognize whether a file was successfully dropped into finder from the JavaFX application. However, the event always reports that it was not accepted. I was under the impression that event.isAccepted() should return true if it was successfully dropped. This is the reproducer:
>
> public class DragDrop extends Application {
> @Override
> public void start(Stage primaryStage) throws Exception {
> var file = Files.createTempFile("test", null);
>
> var r = new Region();
> r.setOnDragDetected(event -> {
> event.setDragDetect(true);
> Dragboard db = r.startDragAndDrop(TransferMode.MOVE);
> var cc = new ClipboardContent();
> cc.putFiles(List.of(file.toFile()));
> db.setContent(cc);
> event.consume();
> });
>
> r.setOnDragDone(event -> {
> System.out.println("Accepted: " + event.isAccepted());
> System.out.println(event);
> });
>
> var scene = new Scene(r, 450, 500);
> primaryStage.setScene(scene);
> primaryStage.setTitle("Test");
> primaryStage.show();
> }
> }
>
>
>
> I looked through the documentation of DragEvent but I'm still not really sure whether this is a bug. The documentation of DragEvent is a little bit light when it comes to behavior of drag events that go to the system itself.
>
> Best
> Christopher Schnick
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20240210/c87ef7bf/attachment-0001.htm>
More information about the openjfx-dev
mailing list