fix hover text and demonstrate it better.
This commit is contained in:
parent
66f6d958d7
commit
a29fdf1c74
|
@ -2520,7 +2520,8 @@ Element.prototype.setHover = function(options) {
|
|||
});
|
||||
|
||||
this.on('mouse', function(data) {
|
||||
if (!self._hover._.over) return;
|
||||
// XXX Does not work as well as it should:
|
||||
// if (!self._hover._.over) return;
|
||||
|
||||
var el = self._hover
|
||||
, x = data.x
|
||||
|
@ -2533,7 +2534,7 @@ Element.prototype.setHover = function(options) {
|
|||
y -= el.rtop;
|
||||
}
|
||||
|
||||
self._hover.rleft = x;
|
||||
self._hover.rleft = x + 1;
|
||||
self._hover.rtop = y;
|
||||
|
||||
self.screen.render();
|
||||
|
@ -2544,6 +2545,13 @@ Element.prototype.setHover = function(options) {
|
|||
self._hover.detach();
|
||||
self.screen.render();
|
||||
});
|
||||
|
||||
this.screen.on('element mouseover', function(el) {
|
||||
if (el === self || el === self._hover) return;
|
||||
self._hover._.over = false;
|
||||
self._hover.detach();
|
||||
self.screen.render();
|
||||
});
|
||||
};
|
||||
|
||||
Element.prototype.removeHover = function() {
|
||||
|
|
|
@ -99,6 +99,10 @@ var list = blessed.list({
|
|||
screen.append(list);
|
||||
list.select(0);
|
||||
|
||||
list.items.forEach(function(item) {
|
||||
item.setHover(item.getText().trim());
|
||||
});
|
||||
|
||||
list.prepend(blessed.text({
|
||||
left: 2,
|
||||
content: ' My list '
|
||||
|
|
Loading…
Reference in New Issue