Show a simple menu in default_app on Windows.

This commit is contained in:
Cheng Zhao 2013-10-02 21:51:19 +08:00
parent 5c8566e0d4
commit 6748573dee

View file

@ -31,7 +31,6 @@ app.on('finish-launching', function() {
}); });
mainWindow.on('closed', function() { mainWindow.on('closed', function() {
console.log('closed');
mainWindow = null; mainWindow = null;
}); });
@ -39,6 +38,7 @@ app.on('finish-launching', function() {
console.log('unresponsive'); console.log('unresponsive');
}); });
if (process.platform == 'darwin') {
var template = [ var template = [
{ {
label: 'Atom Shell', label: 'Atom Shell',
@ -156,14 +156,49 @@ app.on('finish-launching', function() {
]; ];
menu = Menu.buildFromTemplate(template); menu = Menu.buildFromTemplate(template);
if (process.platform == 'darwin')
Menu.setApplicationMenu(menu); Menu.setApplicationMenu(menu);
else } else {
var template = [
{
label: 'File',
submenu: [
{
label: 'Open',
accelerator: 'Command+O',
},
{
label: 'Close',
accelerator: 'Command+W',
click: function() { mainWindow.close(); }
},
]
},
{
label: 'View',
submenu: [
{
label: 'Reload',
accelerator: 'Command+R',
click: function() { mainWindow.restart(); }
},
{
label: 'Enter Fullscreen',
click: function() { mainWindow.setFullscreen(true); }
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: function() { mainWindow.toggleDevTools(); }
},
]
},
];
menu = Menu.buildFromTemplate(template);
mainWindow.setMenu(menu); mainWindow.setMenu(menu);
}
ipc.on('message', function(processId, routingId, type) { ipc.on('message', function(processId, routingId, type) {
console.log(type);
if (type == 'menu') if (type == 'menu')
menu.popup(mainWindow); menu.popup(mainWindow);
}); });