-
Notifications
You must be signed in to change notification settings - Fork 126
Added file drag-n-drop for opening them #3731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -487,6 +489,27 @@ private void startUI(final MementoTree memento, final JobMonitor monitor) throws | |
| toolbar = createToolbar(); | ||
| createTopResourcesMenu(); | ||
|
|
||
| menuBar.setOnDragOver(e -> { | ||
| 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(); | ||
| }); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of calling |
||
|
|
||
| DockStage.configureStage(main_stage); | ||
| // Patch ID of main window | ||
| // (in case we ever need to identify the main window) | ||
|
|
||
There was a problem hiding this comment.
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.