From 99870e063dd444ab93ce6d44addea6dc48a7c85f Mon Sep 17 00:00:00 2001 From: tillvit Date: Wed, 14 Aug 2024 14:49:01 -0700 Subject: [PATCH] Open files by dragging onto the app --- app/src/App.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/src/App.ts b/app/src/App.ts index a6e996c9..ee68240d 100644 --- a/app/src/App.ts +++ b/app/src/App.ts @@ -84,8 +84,23 @@ export class App { const win = nw.Window.get() nw.App.on("open", args => { - console.log(args) - nw.Window.open(window.location.href) + if (!args || args?.length === 0) { + nw.Window.open(window.location.href) + return + } + let foundSM = "" + for (const file of args) { + if (extname(file) == ".ssc") { + foundSM = file + break + } else if (foundSM == "" && extname(file) == ".sm") { + foundSM = file + } + } + if (foundSM != "") { + this.chartManager.loadSM(foundSM) + this.windowManager.getWindowById("select_sm_initial")?.closeWindow() + } }) window.addEventListener("keydown", e => {