Build application menu with the new menu API in default app.
This commit is contained in:
parent
4984f30e48
commit
c5884bf273
1 changed files with 33 additions and 10 deletions
|
@ -2,6 +2,7 @@ var app = require('app');
|
|||
var delegate = require('atom_delegate');
|
||||
var ipc = require('ipc');
|
||||
var Menu = require('menu');
|
||||
var MenuItem = require('menu_item');
|
||||
var BrowserWindow = require('browser_window');
|
||||
|
||||
var mainWindow = null;
|
||||
|
@ -28,19 +29,41 @@ delegate.browserMainParts.preMainMessageLoopRun = function() {
|
|||
});
|
||||
|
||||
menu = new Menu;
|
||||
menu.appendItem(0, 'Open GitHub');
|
||||
|
||||
menu.delegate = {
|
||||
getAcceleratorForCommandId: function(commandId) {
|
||||
if (commandId == 0)
|
||||
return 'Ctrl+g';
|
||||
var appleMenu = new Menu;
|
||||
appleMenu.append(new MenuItem({
|
||||
label: 'About Atom Shell',
|
||||
click: function() {
|
||||
Menu.sendActionToFirstResponder('orderFrontStandardAboutPanel:');
|
||||
}
|
||||
}
|
||||
}));
|
||||
appleMenu.append(new MenuItem({ type: 'separator' }));
|
||||
appleMenu.append(new MenuItem({
|
||||
label: 'Hide Atom Shell',
|
||||
accelerator: 'Command+H',
|
||||
click: function() {
|
||||
Menu.sendActionToFirstResponder('hide:');
|
||||
}
|
||||
}));
|
||||
appleMenu.append(new MenuItem({
|
||||
label: 'Hide Others',
|
||||
accelerator: 'Command+Shift+H',
|
||||
click: function() {
|
||||
Menu.sendActionToFirstResponder('hideOtherApplications:');
|
||||
}
|
||||
}));
|
||||
appleMenu.append(new MenuItem({ type: 'separator' }));
|
||||
appleMenu.append(new MenuItem({
|
||||
label: 'Quit',
|
||||
accelerator: 'Command+Q',
|
||||
click: function() {
|
||||
app.quit();
|
||||
}
|
||||
}));
|
||||
|
||||
menu.on('execute', function(commandId) {
|
||||
if (commandId == 0)
|
||||
mainWindow.loadUrl('https://github.com');
|
||||
});
|
||||
menu.append(new MenuItem({ type: 'submenu', submenu: appleMenu }));
|
||||
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
ipc.on('message', function(processId, routingId, type) {
|
||||
if (type == 'menu')
|
||||
|
|
Loading…
Add table
Reference in a new issue