diff --git a/source/Ox.UI/js/Menu/MainMenu.js b/source/Ox.UI/js/Menu/MainMenu.js index 3f58d22c..03425a84 100644 --- a/source/Ox.UI/js/Menu/MainMenu.js +++ b/source/Ox.UI/js/Menu/MainMenu.js @@ -255,6 +255,12 @@ Ox.MainMenu = function(options, self) { return that; }; + that.setItemKeyboard = function(id, keyboard) { + var item = that.getItem(id); + item && item.options({keyboard: keyboard}); + return that; + }; + /*@ setItemTitle setItemTitle (id, title) -> set item title diff --git a/source/Ox.UI/js/Menu/Menu.js b/source/Ox.UI/js/Menu/Menu.js index 64b7356b..e4d52037 100644 --- a/source/Ox.UI/js/Menu/Menu.js +++ b/source/Ox.UI/js/Menu/Menu.js @@ -770,6 +770,12 @@ Ox.Menu = function(options, self) { return that; }; + that.setItemKeyboard = function(id, keyboard) { + var item = that.getItem(id); + item && item.options({keyboard: keyboard}); + return that; + }; + /*@ setItemTitle setItemTitle (id, title) -> set item title diff --git a/source/Ox.UI/js/Menu/MenuItem.js b/source/Ox.UI/js/Menu/MenuItem.js index 8dab61d1..37d03df7 100644 --- a/source/Ox.UI/js/Menu/MenuItem.js +++ b/source/Ox.UI/js/Menu/MenuItem.js @@ -53,6 +53,11 @@ Ox.MenuItem = function(options, self) { disabled: self.options.disabled }); }, + keyboard: function() { + self.options.keyboard = parseKeyboard(self.options.keyboard); + that.$modifiers.html(formatModifiers()); + that.$key.html(formatKey()); + }, title: function() { self.options.title = Ox.makeArray(self.options.title); that.$title.html(self.options.title[0]); @@ -116,11 +121,7 @@ Ox.MenuItem = function(options, self) { .append( that.$modifiers = Ox.$('') .addClass('OxCell OxModifiers') - .html( - self.options.keyboard.modifiers.map(function(modifier) { - return Ox.UI.symbols[modifier]; - }).join('') - ) + .html(formatModifiers()) ) .append( that.$key = Ox.$('') @@ -130,11 +131,21 @@ Ox.MenuItem = function(options, self) { .html( self.options.items.length ? Ox.UI.symbols.triangle_right - : Ox.UI.symbols[self.options.keyboard.key] - || self.options.keyboard.key.toUpperCase() + : formatKey() ) ); + function formatKey() { + return Ox.UI.symbols[self.options.keyboard.key] + || self.options.keyboard.key.toUpperCase(); + } + + function formatModifiers() { + return self.options.keyboard.modifiers.map(function(modifier) { + return Ox.UI.symbols[modifier]; + }).join(''); + } + function parseKeyboard(str) { var modifiers = str.split(' '), key = modifiers.pop();