Support Mac Drop-on-Dock file events

This commit is contained in:
Reinhard Pointner 2016-03-19 17:31:14 +00:00
parent 372a46a933
commit 508dced94a
1 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import java.util.function.Consumer;
import java.util.logging.Level;
import javax.swing.JMenuBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import com.apple.eawt.Application;
@ -138,7 +139,12 @@ public class MacAppUtilities {
public static void setOpenFileHandler(Consumer<List<File>> handler) {
try {
Application.getApplication().setOpenFileHandler(evt -> handler.accept(evt.getFiles()));
Application.getApplication().setOpenFileHandler(evt -> {
List<File> files = evt.getFiles();
if (files.size() > 0) {
SwingUtilities.invokeLater(() -> handler.accept(evt.getFiles()));
}
});
} catch (Throwable t) {
debug.log(Level.WARNING, t.getMessage(), t);
}