diff --git a/lib/widget.js b/lib/widget.js index 34b7605..50f5c86 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -5887,6 +5887,10 @@ Listbar.prototype.appendItem = function(item, callback) { }; } + if (cmd.keys && cmd.keys[0]) { + cmd.prefix = cmd.keys[0]; + } + title = (cmd.prefix != null ? '{light-black-fg}' + cmd.prefix + '{/light-black-fg}' @@ -5941,7 +5945,16 @@ Listbar.prototype.appendItem = function(item, callback) { if (cmd.callback) { //el.on('press', cmd.callback); if (cmd.keys) { - this.screen.key(cmd.keys, cmd.callback); + this.screen.key(cmd.keys, function(ch, key) { + self.emit('action', el, self.selected); + self.emit('select', el, self.selected); + //el.press(); + if (el._.cmd.callback) { + el._.cmd.callback(); + } + self.select(el); + self.screen.render(); + }); } } diff --git a/test/widget-listbar.js b/test/widget-listbar.js index ab34dea..4fe45c8 100644 --- a/test/widget-listbar.js +++ b/test/widget-listbar.js @@ -46,9 +46,12 @@ var bar = blessed.listbar({ } }, commands: { - 'one': function() { - box.setContent('Pressed one.'); - screen.render(); + 'one': { + keys: ['a'], + callback: function() { + box.setContent('Pressed one.'); + screen.render(); + } }, 'two': function() { box.setContent('Pressed two.');