File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/main/java/com/tridevmc/dolphintortcmap Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,31 @@ public void start(Stage stage) throws IOException {
2020 stage .setScene (scene );
2121
2222 // Check if a file was passed as an argument, if it was then tell the LinkerMapToRTCMapController to load it.
23- if (!getParameters ().getRaw ().isEmpty ()) {
23+ if (!getParameters ().getRaw ().isEmpty ()) {
2424 File file = new File (getParameters ().getRaw ().getFirst ());
2525 LinkerMapToRTCMapController controller = fxmlLoader .getController ();
2626 controller .loadFile (file );
2727 }
2828
29+ // Add a drag and drop listener that will load the file when a file is dropped onto the window.
30+ scene .setOnDragOver (event -> {
31+ if (event .getDragboard ().hasFiles ()) {
32+ event .acceptTransferModes (javafx .scene .input .TransferMode .COPY );
33+ }
34+ event .consume ();
35+ });
36+
37+ scene .setOnDragDropped (event -> {
38+ var db = event .getDragboard ();
39+ if (db .hasFiles ()) {
40+ File file = db .getFiles ().getFirst ();
41+ LinkerMapToRTCMapController controller = fxmlLoader .getController ();
42+ controller .loadFile (file );
43+ }
44+ event .setDropCompleted (true );
45+ event .consume ();
46+ });
47+
2948 stage .show ();
3049 }
3150
You can’t perform that action at this time.
0 commit comments