Convert generic accelerator to platform accelerator.
When creating menus, the accelerators must be converted to platform accelerators before they can be used.
This commit is contained in:
parent
995b9dacc9
commit
b16c19ce32
4 changed files with 42 additions and 0 deletions
|
@ -43,6 +43,7 @@ bool StringToAccelerator(const std::string& description,
|
|||
std::vector<std::string> tokens;
|
||||
base::SplitString(shortcut, '+', &tokens);
|
||||
if (tokens.size() < 2 || tokens.size() > 3) {
|
||||
LOG(WARNING) << "Invalid accelerator description: " << description;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -69,15 +70,18 @@ bool StringToAccelerator(const std::string& description,
|
|||
} else if (tokens[i][0] >= '0' && tokens[i][0] <= '9') {
|
||||
key = static_cast<ui::KeyboardCode>(ui::VKEY_0 + (tokens[i][0] - '0'));
|
||||
} else {
|
||||
LOG(WARNING) << "Invalid accelerator character: " << tokens[i];
|
||||
key = ui::VKEY_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LOG(WARNING) << "Invalid accelerator token: " << tokens[i];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*accelerator = ui::Accelerator(key, modifiers);
|
||||
SetPlatformAccelerator(accelerator);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue