Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy-paste support #19

Merged
merged 3 commits into from
Nov 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Copy-paste support
Mars Geldard authored and Mars Geldard committed Nov 26, 2018
commit c937ae5c847062e40528ec36239156824086750c
61 changes: 61 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Requirements
const {app, BrowserWindow, ipcMain} = require('electron')
const Menu = require('electron').Menu
const autoUpdater = require('electron-updater').autoUpdater
const ejse = require('ejs-electron')
const fs = require('fs')
@@ -123,6 +124,65 @@ function createWindow() {
})
}

function createMenu() {

// Extend default included application menu to continue support for quit keyboard shortcut
let applicationSubMenu = {
label: "Application",
submenu: [{
label: "About Application",
selector: "orderFrontStandardAboutPanel:"
}, {
type: "separator"
}, {
label: "Quit",
accelerator: "Command+Q",
click: () => {
app.quit()
}
}]
}

// New edit menu adds support for text-editing keyboard shortcuts
let editSubMenu = {
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:"
}]
}

// Bundle submenus into a single template and build a menu object with it
let menuTemplate = [applicationSubMenu, editSubMenu]
let menuObject = Menu.buildFromTemplate(menuTemplate)

// Assign it to the application
Menu.setApplicationMenu(menuObject)
}

function getPlatformIcon(filename){
const opSys = process.platform
if (opSys === 'darwin') {
@@ -137,6 +197,7 @@ function getPlatformIcon(filename){
}

app.on('ready', createWindow)
app.on('ready', createMenu)

app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar