Convert "Command" to "Ctrl" in accelerators on non-Mac.

This commit is contained in:
Cheng Zhao 2013-10-04 22:59:05 +08:00
parent ae98d9c8b6
commit 32432cc770
2 changed files with 5 additions and 8 deletions

View file

@ -15,10 +15,9 @@ namespace accelerator_util {
namespace { namespace {
// For Mac, we convert "Ctrl" to "Command" and "MacCtrl" to "Ctrl". Other // Convert "Command" to "Ctrl" on non-Mac
// platforms leave the shortcut untouched.
std::string NormalizeShortcutSuggestion(const std::string& suggestion) { std::string NormalizeShortcutSuggestion(const std::string& suggestion) {
#if !defined(OS_MACOSX) #if defined(OS_MACOSX)
return suggestion; return suggestion;
#endif #endif
@ -26,9 +25,7 @@ std::string NormalizeShortcutSuggestion(const std::string& suggestion) {
std::vector<std::string> tokens; std::vector<std::string> tokens;
base::SplitString(suggestion, '+', &tokens); base::SplitString(suggestion, '+', &tokens);
for (size_t i = 0; i < tokens.size(); i++) { for (size_t i = 0; i < tokens.size(); i++) {
if (tokens[i] == "Ctrl") if (tokens[i] == "Command")
tokens[i] = "Command";
else if (tokens[i] == "MacCtrl")
tokens[i] = "Ctrl"; tokens[i] = "Ctrl";
} }
return JoinString(tokens, '+'); return JoinString(tokens, '+');

View file

@ -23,5 +23,5 @@
## Notes on accelerator ## Notes on accelerator
On OS X, the `Ctrl` would automatically translated to `Command`, if you really On Linux and Windows, the `Command` would be translated to `Ctrl`, so usually
want `Ctrl` on OS X, you should use `MacCtrl`. you can use `Command` for most of the commands.