Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Add copy & paste support via menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-denry committed Apr 26, 2019
1 parent 0a226d7 commit 0e52425
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
67 changes: 67 additions & 0 deletions js/menu-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Module for Menu functions.
*/

const {app, Menu} = require('electron')

let menuService = {}

menuService.createMenu = () => {
const application = {
label: 'Chimeverse',
submenu: [
{
label: 'Quit',
accelerator: 'Command+Q',
click: () => {
app.quit()
},
},
],
}

const edit = {
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'CmdOrCtrl+Z',
role: 'undo',
},
{
label: 'Redo',
accelerator: 'Shift+CmdOrCtrl+Z',
role: 'redo',
},
{
type: 'separator',
},
{
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
role: 'cut',
},
{
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
role: 'copy',
},
{
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
role: 'paste',
},
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
role: 'selectAll',
},
],
}

const template = [application, edit]

Menu.setApplicationMenu(Menu.buildFromTemplate(template))
}

module.exports = menuService
4 changes: 4 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let mainWindow

// Require other app modules
const trayService = require(__dirname+'/js/tray-service')
const menuService = require(__dirname+'/js/menu-service')

function initApp() {
createWindow()
Expand All @@ -28,6 +29,9 @@ function createWindow () {
// Init tray
trayService.initTray(mainWindow)

// Init menu
menuService.createMenu()

// Open the DevTools.
// mainWindow.webContents.openDevTools()

Expand Down

0 comments on commit 0e52425

Please sign in to comment.