Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
Expand Down Expand Up @@ -487,6 +489,27 @@ private void startUI(final MementoTree memento, final JobMonitor monitor) throws
toolbar = createToolbar();
createTopResourcesMenu();

menuBar.setOnDragOver(e -> {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be a good location to put this event method? Because the event-handler should be shared, as I would like it to be called from other panels too.

final Dragboard db = e.getDragboard();
if (db.hasFiles()) // Allow any drag operation containing files
e.acceptTransferModes(TransferMode.MOVE);

e.consume();
});

menuBar.setOnDragDropped(e -> {
final Dragboard db = e.getDragboard();

if (db.hasFiles()) {
for (File file : db.getFiles()) {
this.openResource(file.toURI(), true);
}
}

e.setDropCompleted(true);
e.consume();
});
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but causes the dragged-file icon to still show on top of the UI file the 'Choose editor' dialog is open.
What is a neat way to delay the openResource() call by a little bit?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling this.openResource(...) right there, try deferring it to the next UI cycle via

 Platform.runLater(() -> this.openResource(...));


DockStage.configureStage(main_stage);
// Patch ID of main window
// (in case we ever need to identify the main window)
Expand Down