From 234048109fca8b008949877619be886654220d19 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 9 May 2024 09:56:11 +0000 Subject: [PATCH] Fix file browser dragboard mime type for macos --- .../java/io/xpipe/app/browser/BrowserClipboard.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java b/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java index ba9761b48..52265e633 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserClipboard.java @@ -11,6 +11,7 @@ import io.xpipe.core.util.FailableRunnable; import javafx.beans.property.Property; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.input.ClipboardContent; +import javafx.scene.input.DataFormat; import javafx.scene.input.Dragboard; import lombok.SneakyThrows; import lombok.Value; @@ -29,6 +30,7 @@ public class BrowserClipboard { public static final Property currentCopyClipboard = new SimpleObjectProperty<>(); public static Instance currentDragClipboard; + private static final DataFormat DATA_FORMAT = new DataFormat("application/xpipe-file-list"); static { Toolkit.getDefaultToolkit() @@ -72,7 +74,7 @@ public class BrowserClipboard { var content = new ClipboardContent(); var id = UUID.randomUUID(); currentDragClipboard = new Instance(id, base, new ArrayList<>(selected), mode); - content.putString(currentDragClipboard.toClipboardString()); + content.put(DATA_FORMAT, currentDragClipboard.toClipboardString()); return content; } @@ -92,16 +94,12 @@ public class BrowserClipboard { } public static Instance retrieveDrag(Dragboard dragboard) { - if (dragboard.getString() == null) { - return null; - } - if (currentDragClipboard == null) { return null; } try { - var s = dragboard.getString(); + var s = dragboard.getContent(DATA_FORMAT); if (s != null && s.equals(currentDragClipboard.toClipboardString())) { var current = currentDragClipboard; currentDragClipboard = null;