From 8237edcf0d1829a50e9dc141d258b01fb7b84010 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 29 Nov 2013 16:10:32 +0800 Subject: [PATCH] Add "CommandOrControl" to represent "Command" on OS X and "Ctrl" on other platforms. --- browser/ui/accelerator_util.cc | 6 ++++++ docs/api/browser/menu-item.md | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/browser/ui/accelerator_util.cc b/browser/ui/accelerator_util.cc index 1fb89a7e23..b2aadb93a2 100644 --- a/browser/ui/accelerator_util.cc +++ b/browser/ui/accelerator_util.cc @@ -109,6 +109,12 @@ bool StringToAccelerator(const std::string& description, modifiers |= ui::EF_CONTROL_DOWN; } else if (tokens[i] == "command") { modifiers |= ui::EF_COMMAND_DOWN; + } else if (tokens[i] == "commandorcontrol" || tokens[i] == "cmdorctrl") { +#if defined(OS_MACOSX) + modifiers |= ui::EF_COMMAND_DOWN; +#else + modifiers |= ui::EF_CONTROL_DOWN; +#endif } else if (tokens[i] == "alt") { modifiers |= ui::EF_ALT_DOWN; } else if (tokens[i] == "shift") { diff --git a/docs/api/browser/menu-item.md b/docs/api/browser/menu-item.md index 6ad24d94e0..ddf8d13c3e 100644 --- a/docs/api/browser/menu-item.md +++ b/docs/api/browser/menu-item.md @@ -23,4 +23,7 @@ ## Notes on accelerator -On Linux and Windows, the `Command` key would not have any effect. +On Linux and Windows, the `Command` key would not have any effect, you can +use `CommandOrControl` which represents `Command` on OS X and `Control` on +Linux and Windows to define some accelerators, you can also use its short +alias `CmdOrCtrl`.