-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.js
77 lines (71 loc) · 1.6 KB
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Modules
const {Menu, shell} = require('electron')
// Module function to create main app menu
module.exports = appWin => {
// Menu template
let template = [
{
label: 'Items',
submenu: [
{
label: 'Add New',
accelerator: 'CmdOrCtrl+O',
click: () => {
appWin.send('menu-show-modal')
}
},
{
label: 'Read Item',
accelerator: 'CmdOrCtrl+Enter',
click: () => {
appWin.send('menu-open-item')
}
},
{
label: 'Delete Item',
accelerator: 'CmdOrCtrl+Backspace',
click: () => {
appWin.send('menu-delete-item')
}
},
{
label: 'Open in Browser',
accelerator: 'CmdOrCtrl+Shift+Enter',
click: () => {
appWin.send('menu-open-item-native')
}
},
{
label: 'Search Items',
accelerator: 'CmdOrCtrl+S',
click: () => {
appWin.send('menu-focus-search')
}
}
]
},
{
role: 'editMenu'
},
{
role: 'windowMenu'
},
{
role: 'help',
submenu: [
{
label: 'Learn more',
click: () => {
shell.openExternal('https://github.com/stackacademytv/master-electron')
}
}
]
}
]
// Create Mac app menu
if ( process.platform === 'darwin' ) template.unshift({ role: 'appMenu' })
// Build menu
let menu = Menu.buildFromTemplate(template)
// Set as main app menu
Menu.setApplicationMenu(menu)
}