Commit 35063fc4 authored by jackhou@chromium.org's avatar jackhou@chromium.org

Explicitly use Cmd+w for "Close Window" in apps. (Mac)

Previously, the "Close Window" item is copied from Chrome's "File" menu.
However, the key equivalent of this item changes between Cmd+Shift+w and
Cmd+w depending on whether a tabbed window has focus. This happens in
-[AppControllerMac adjustCloseWindowMenuItemKeyEquivalent:].

This causes a bug when the item in the app's menu does not match the one
in Chrome's. OSX will remove the keyboard shortcut for any items that have
a matching title but different key equivalents. 

In this CL, the key equivalent is always set to Cmd+w in the app's menu. The "Close Window" item in Chrome will be changed to Cmd+w when an app
window gains focus. Duplicate items are allowed to share a key equivalent
if their titles match.

BUG=302117

Review URL: https://codereview.chromium.org/130673002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244133 0039d316-1c4b-4281-b951-d872f2087c98
parent ece777ae
......@@ -237,6 +237,12 @@ void AddDuplicateItem(NSMenuItem* top_level_item,
[[fileMenuItem_ submenu] addItem:[openDoppelganger_ menuItem]];
[[fileMenuItem_ submenu] addItem:[NSMenuItem separatorItem]];
AddDuplicateItem(fileMenuItem_, IDC_FILE_MENU, IDC_CLOSE_WINDOW);
// Set the expected key equivalent explicitly here because
// -[AppControllerMac adjustCloseWindowMenuItemKeyEquivalent:] sets it to
// "W" (Cmd+Shift+w) when a tabbed window has focus; it will change it back
// to Cmd+w when a non-tabbed window has focus.
[[[fileMenuItem_ submenu] itemWithTag:IDC_CLOSE_WINDOW]
setKeyEquivalent:@"w"];
// Edit menu. This copies the menu entirely and removes
// "Paste and Match Style" and "Find". This is because the last two items,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment