allow menu item to trigger native file dialog when pressing enter
This commit is contained in:
parent
7818d4deb6
commit
826eb5548d
3 changed files with 22 additions and 7 deletions
|
@ -100,6 +100,14 @@ Ox.FileButton = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
that.blurButton = function() {
|
||||
self.$input.blur();
|
||||
}
|
||||
|
||||
that.focusButton = function() {
|
||||
self.$input.focus();
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
}
|
|
@ -439,9 +439,14 @@ Ox.Menu = function(options, self) {
|
|||
function selectItem(position) {
|
||||
var item;
|
||||
if (self.options.selected > -1) {
|
||||
//Ox.Log('Menu', 's.o.s', self.options.selected, that.items)
|
||||
item = that.items[self.options.selected]
|
||||
item && item.removeClass('OxSelected');
|
||||
item = that.items[self.options.selected];
|
||||
if (item) {
|
||||
item.removeClass('OxSelected');
|
||||
if (item.options('file')) {
|
||||
item.$button.blurButton();
|
||||
that.bindEvent({key_enter: clickSelectedItem})
|
||||
}
|
||||
}
|
||||
/* disabled
|
||||
that.triggerEvent('deselect', {
|
||||
id: item.options('id'),
|
||||
|
@ -457,15 +462,17 @@ Ox.Menu = function(options, self) {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
item.options('items').length && that.submenus[item.options('id')].showMenu(); // fixme: do we want to switch to this style?
|
||||
item.options('items').length && that.submenus[item.options('id')].showMenu();
|
||||
item.addClass('OxSelected');
|
||||
///* disabled
|
||||
if (item.options('file')) {
|
||||
item.$button.focusButton();
|
||||
that.unbindEvent('key_enter');
|
||||
}
|
||||
that.triggerEvent('select', {
|
||||
id: item.options('id'),
|
||||
title: Ox.isString(item.options('title')[0])
|
||||
? Ox.stripTags(item.options('title')[0]) : ''
|
||||
});
|
||||
//*/
|
||||
}
|
||||
self.options.selected = position;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ Ox.MenuItem = function(options, self) {
|
|||
.html(
|
||||
self.options.file
|
||||
?
|
||||
Ox.FileButton(Ox.extend(Ox.clone(self.options.file), {
|
||||
that.$button = Ox.FileButton(Ox.extend(Ox.clone(self.options.file), {
|
||||
title: self.options.title[0],
|
||||
width: self.options.file.width
|
||||
})).bindEvent({
|
||||
|
|
Loading…
Reference in a new issue