Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Better menu implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
vtardia committed Jun 29, 2016
1 parent bf431c6 commit 29da1c7
Showing 1 changed file with 5 additions and 49 deletions.
54 changes: 5 additions & 49 deletions app/lib/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,24 @@ var menuTemplate = [
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'
}
]
Expand All @@ -65,19 +53,7 @@ var menuTemplate = [
}
},
{
label: 'Toggle Full Screen',
accelerator: (function () {
if (process.platform === 'darwin') {
return 'Ctrl+Command+F'
} else {
return 'F11'
}
})(),
click: function (item, focusedWindow) {
if (focusedWindow) {
focusedWindow.setFullScreen(!focusedWindow.isFullScreen())
}
}
role: 'togglefullscreen'
}
]
},
Expand All @@ -86,13 +62,9 @@ var menuTemplate = [
role: 'window',
submenu: [
{
label: 'Minimize',
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
label: 'Close',
accelerator: 'CmdOrCtrl+W',
role: 'close'
}
]
Expand All @@ -116,63 +88,48 @@ if (isDev) {
menuTemplate[1].submenu.push(
{
label: 'Toggle Developer Tools',
accelerator: (function () {
if (process.platform === 'darwin') {
return 'Alt+Command+I'
} else {
return 'Ctrl+Shift+I'
}
})(),
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click: function (item, focusedWindow) {
if (focusedWindow) {
focusedWindow.toggleDevTools()
focusedWindow.webContents.toggleDevTools()
}
}
}
)
}

if (process.platform === 'darwin') {
var name = require('electron').app.getName()
var name = app.getName()
menuTemplate.unshift({
label: name,
submenu: [
{
label: 'About ' + name,
role: 'about'
},
{
type: 'separator'
},
{
label: 'Services',
role: 'services',
submenu: []
},
{
type: 'separator'
},
{
label: 'Hide ' + name,
accelerator: 'Command+H',
role: 'hide'
},
{
label: 'Hide Others',
accelerator: 'Command+Alt+H',
role: 'hideothers'
},
{
label: 'Show All',
role: 'unhide'
},
{
type: 'separator'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click: function () { app.quit() }
role: 'quit'
}
]
})
Expand All @@ -182,7 +139,6 @@ if (process.platform === 'darwin') {
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
}
)
Expand Down

0 comments on commit 29da1c7

Please sign in to comment.