diff --git a/src/Ation.js b/src/Ation.js index 78caad7..9b58aa3 100644 --- a/src/Ation.js +++ b/src/Ation.js @@ -40,7 +40,7 @@ class Ation { if (!this.windowManager.mainWindow) return null; - const result = await dialog.showOpenDialog(this.mainWindow, { + const result = await dialog.showOpenDialog(this.windowManager.mainWindow, { title : "open file", filters : [ { @@ -57,7 +57,8 @@ class Ation { const basePath = path.dirname(result.filePaths[0]); const data = parser(fileContents); - return [basePath, data]; + + this.windowManager.mainWindow.send("Ation::openFile", [basePath, data]); } } Ation.Instances = 0; diff --git a/src/MainMenu.js b/src/MainMenu.js index ba37ac9..86ddf79 100644 --- a/src/MainMenu.js +++ b/src/MainMenu.js @@ -15,6 +15,16 @@ class MainMenu { ...(process.platform === "darwin" ? [{ role : "appMenu" }] : []), + { + label : "File", + submenu : [ + { + label : "Open", + accelerator : "CommandOrControl+O", + click : () => this.app.openFile() + } + ] + }, { role : "windowMenu" } diff --git a/src/WindowManager.js b/src/WindowManager.js index 558e510..e87e035 100644 --- a/src/WindowManager.js +++ b/src/WindowManager.js @@ -17,7 +17,7 @@ class WindowManager { app.whenReady().then(() => this.init()); - ipcMain.handle("WindowManager::openFile", async () => this.app.openFile()); + ipcMain.on("WindowManager::openFileDialog", () => this.app.openFile()); } init() {