Allow platform-specific bindings to clobber generic bindings

This commit is contained in:
Jason San Jose 2012-12-20 11:37:50 -08:00
Родитель 812dab2c28
Коммит 59a0a8f752
2 изменённых файлов: 19 добавлений и 14 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -1,4 +1,5 @@
Thumbs.db
node_modules
src/brackets.css
src/brackets.min.css

Просмотреть файл

@ -145,7 +145,6 @@ define(function (require, exports, module) {
} else if (_compareModifierString("alt", ele, hasAlt, origDescriptor)) {
hasAlt = true;
} else if (_compareModifierString("opt", ele, hasAlt, origDescriptor)) {
console.log("KeyBindingManager normalizeKeyDescriptorString() - Opt getting mapped to Alt from: " + origDescriptor);
hasAlt = true;
} else if (_compareModifierString("shift", ele, hasShift, origDescriptor)) {
hasShift = true;
@ -352,7 +351,8 @@ define(function (require, exports, module) {
explicitPlatform = keyBinding.platform || platform,
targetPlatform = explicitPlatform || brackets.platform,
command,
bindingsToDelete = [];
bindingsToDelete = [],
existing = _keyMap[key];
key = (keyBinding.key) || keyBinding;
if (brackets.platform === "mac" && explicitPlatform === undefined) {
@ -369,20 +369,11 @@ define(function (require, exports, module) {
return null;
}
// skip if the key is already assigned
if (_isKeyAssigned(normalized)) {
console.log("Cannot assign " + normalized + " to " + commandID +
". It is already assigned to " + _keyMap[normalized].commandID);
return null;
}
// for cross-platform compatibility
if (exports.useWindowsCompatibleBindings) {
// windows-only key bindings are used as the default binding
// only if a default binding wasn't already defined
if (explicitPlatform === "win") {
// windows-only key bindings are used as the default binding
// only if a default binding wasn't already defined
var existing = _keyMap[normalized];
// search for a generic or platform-specific binding if it
// already exists
if (existing &&
@ -401,6 +392,20 @@ define(function (require, exports, module) {
return null;
}
// skip if the key is already assigned explicitly for this platform
if (existing) {
if (!existing.platform) {
// remove existing generic bindings, then re-map this binding
// to the new command
removeBinding(normalized);
} else {
// do not re-assign a platform-specific key binding
console.log("Cannot assign " + normalized + " to " + commandID +
". It is already assigned to " + _keyMap[normalized].commandID);
return null;
}
}
// delete existing bindings when
// (1) replacing a windows-compatible binding with a generic or
// platform-specific binding
@ -520,7 +525,6 @@ define(function (require, exports, module) {
}
var normalizedBindings = [],
targetPlatform,
results;
if (Array.isArray(keyBindings)) {