Enable copy paste for mac?

master
Rohan Vazarkar 2016-09-02 18:06:15 -04:00
parent 0f349f1de9
commit 2c39815317
1 changed files with 30 additions and 4 deletions

34
main.js
View File

@ -3,6 +3,8 @@ var platform = require('os').platform()
// Module to control application life. // Module to control application life.
const app = electron.app const app = electron.app
const Tray = electron.Tray const Tray = electron.Tray
const Menu = electron.Menu
// Module to create native browser window. // Module to create native browser window.
const BrowserWindow = electron.BrowserWindow const BrowserWindow = electron.BrowserWindow
@ -19,9 +21,7 @@ function createWindow () {
}else{ }else{
mainWindow = new BrowserWindow({width: 1280, height: 800, icon: __dirname + '/src/img/icon.ico'}) mainWindow = new BrowserWindow({width: 1280, height: 800, icon: __dirname + '/src/img/icon.ico'})
} }
//appIcon = new Tray(trayIcon)
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`) mainWindow.loadURL(`file://${__dirname}/index.html`)
// Open the DevTools. // Open the DevTools.
@ -34,12 +34,38 @@ function createWindow () {
// when you should delete the corresponding element. // when you should delete the corresponding element.
mainWindow = null mainWindow = null
}) })
var template = [{
label: "Application",
submenu: [
{ label: "Quit", accelerator: "Command+Q", click: function() { app.quit(); }}
]}, {
label: "Edit",
submenu: [
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
{ type: "separator" },
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" },
{ label: "Reload", accelerator: 'CmdOrCtrl+R', click (item, focusedWindow){
if (focusedWindow) focusedWindow.reload()
}}
]}
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
mainWindow.setMenuBarVisibility(false)
} }
// This method will be called when Electron has finished // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.on('ready', createWindow) app.on('ready', function(){
createWindow()
mainWindow.maximize()
})
// Quit when all windows are closed. // Quit when all windows are closed.
app.on('window-all-closed', function () { app.on('window-all-closed', function () {