added "File -> Open" menu item to main menu

addresses #2
pull/2/head
Michael Ochmann 3 years ago
parent 4cbc2bf384
commit e6449e78dd
  1. 5
      src/Ation.js
  2. 10
      src/MainMenu.js
  3. 2
      src/WindowManager.js

@ -40,7 +40,7 @@ class Ation {
if (!this.windowManager.mainWindow) if (!this.windowManager.mainWindow)
return null; return null;
const result = await dialog.showOpenDialog(this.mainWindow, { const result = await dialog.showOpenDialog(this.windowManager.mainWindow, {
title : "open file", title : "open file",
filters : [ filters : [
{ {
@ -57,7 +57,8 @@ class Ation {
const basePath = path.dirname(result.filePaths[0]); const basePath = path.dirname(result.filePaths[0]);
const data = parser(fileContents); const data = parser(fileContents);
return [basePath, data];
this.windowManager.mainWindow.send("Ation::openFile", [basePath, data]);
} }
} }
Ation.Instances = 0; Ation.Instances = 0;

@ -15,6 +15,16 @@ class MainMenu {
...(process.platform === "darwin" ? [{ ...(process.platform === "darwin" ? [{
role : "appMenu" role : "appMenu"
}] : []), }] : []),
{
label : "File",
submenu : [
{
label : "Open",
accelerator : "CommandOrControl+O",
click : () => this.app.openFile()
}
]
},
{ {
role : "windowMenu" role : "windowMenu"
} }

@ -17,7 +17,7 @@ class WindowManager {
app.whenReady().then(() => this.init()); app.whenReady().then(() => this.init());
ipcMain.handle("WindowManager::openFile", async () => this.app.openFile()); ipcMain.on("WindowManager::openFileDialog", () => this.app.openFile());
} }
init() { init() {

Loading…
Cancel
Save