key->prefix for listbar. misc.
This commit is contained in:
parent
3766ffaa38
commit
4cebb15918
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.');
|
||||
|
|
Loading…
Reference in New Issue