Permalink
Browse files

Merge pull request #990 from adobe/jason-sanjose/issue989

Correctly find the existing menu item shortcut label
  • Loading branch information...
2 parents a325465 + 9455808 commit ccc03cd6ad4bbc179126ee1bfb40fb9ac02eafdd @njx njx committed Jun 3, 2012
Showing with 28 additions and 5 deletions.
  1. +2 −2 src/command/Menus.js
  2. +26 −3 test/spec/Menu-test.js
@@ -126,9 +126,9 @@ define(function (require, exports, module) {
}
function _addKeyBindingToMenuItem($menuItem, key, displayKey) {
- var $shortcut;
+ var $shortcut = $menuItem.find(".menu-shortcut");
- if ($menuItem.find(".menu-shortcut").length === 0) {
+ if ($shortcut.length === 0) {
$shortcut = $("<span class='menu-shortcut'/>");
$menuItem.append($shortcut);
}
@@ -29,6 +29,7 @@ define(function (require, exports, module) {
var CommandManager,
Commands,
+ KeyBindingManager,
Menus,
SpecRunnerUtils = require("./SpecRunnerUtils.js"),
Strings = require("strings");
@@ -42,9 +43,10 @@ define(function (require, exports, module) {
testWindow = w;
// Load module instances from brackets.test
- CommandManager = testWindow.brackets.test.CommandManager;
- Commands = testWindow.brackets.test.Commands;
- Menus = testWindow.brackets.test.Menus;
+ CommandManager = testWindow.brackets.test.CommandManager;
+ Commands = testWindow.brackets.test.Commands;
+ KeyBindingManager = testWindow.brackets.test.KeyBindingManager;
+ Menus = testWindow.brackets.test.Menus;
});
});
@@ -421,6 +423,27 @@ define(function (require, exports, module) {
expect($($menuItem).hasClass("disabled")).toBeFalsy();
});
});
+
+ it("should respond to key binding updates", function () {
+ runs(function () {
+ var menu = Menus.addMenu("Custom", "menu-custom");
+ var menuItem = menu.addMenuItem("menuitem-custom-0", "custom.command0", "Ctrl-9");
+ var menuSelector = "#menuitem-custom-0";
+
+ // Verify menu is synced with command
+ var $menuItem = testWindow.$(menuSelector),
+ $shortcut = $menuItem.find(".menu-shortcut");
+
+ // verify key data instead of platform-specific labels
+ expect($shortcut.data("key")).toBe("Ctrl-9");
+
+ // change keyboard shortcut
+ KeyBindingManager.addBinding("custom.command0", "Alt-8");
+
+ // verify updated keyboard shortcut
+ expect($shortcut.data("key")).toBe("Alt-8");
+ });
+ });
});
});
});

0 comments on commit ccc03cd

Please sign in to comment.