diff --git a/lib/widgets/listbar.js b/lib/widgets/listbar.js index 2f6ff71..d05cc55 100644 --- a/lib/widgets/listbar.js +++ b/lib/widgets/listbar.js @@ -298,6 +298,17 @@ Listbar.prototype.select = function(offset) { offset = this.items.indexOf(offset); } + if (offset < 0) { + offset = 0; + } else if (offset >= this.items.length) { + offset = this.items.length - 1; + } + + if (!this.parent) { + this.emit('select item', el, offset); + return; + } + var lpos = this._getCoords(); if (!lpos) return; @@ -307,12 +318,6 @@ Listbar.prototype.select = function(offset) { , visible = 0 , el; - if (offset < 0) { - offset = 0; - } else if (offset >= this.items.length) { - offset = this.items.length - 1; - } - el = this.items[offset]; if (!el) return;