Automatically convert menu with tile of 'Window' to Window menu in application menu.

This commit is contained in:
Cheng Zhao 2013-05-16 20:48:09 +08:00
parent 84c320ea7f
commit fae3137463
2 changed files with 32 additions and 2 deletions

View file

@ -67,8 +67,14 @@ void MenuMac::FixMenuTitles(NSMenu* menu) {
int size = [menu numberOfItems];
for (int i = 0; i < size; ++i) {
NSMenuItem* item = [menu itemAtIndex:i];
if ([item hasSubmenu])
[[item submenu] setTitle:[item title]];
if ([item hasSubmenu]) {
NSString* title = [item title];
NSMenu* submenu = [item submenu];
[submenu setTitle:title];
if ([title isEqualToString:@"Window"] && [submenu numberOfItems] > 0)
[NSApp setWindowsMenu:submenu];
}
}
}

View file

@ -61,7 +61,31 @@ delegate.browserMainParts.preMainMessageLoopRun = function() {
}
}));
var windowMenu = new Menu;
windowMenu.append(new MenuItem({
label: 'Minimize',
accelerator: 'Command+M',
click: function() {
Menu.sendActionToFirstResponder('performMiniaturize:');
}
}));
windowMenu.append(new MenuItem({
label: 'Close',
accelerator: 'Command+W',
click: function() {
Menu.sendActionToFirstResponder('performClose:');
}
}));
windowMenu.append(new MenuItem({ type: 'separator' }));
windowMenu.append(new MenuItem({
label: 'Bring All to Front',
click: function() {
Menu.sendActionToFirstResponder('arrangeInFront:');
}
}));
menu.append(new MenuItem({ type: 'submenu', submenu: appleMenu }));
menu.append(new MenuItem({ label: 'Window', type: 'submenu', submenu: windowMenu }));
Menu.setApplicationMenu(menu);