From 2d6eb315c47ea5064b8ec93b98ecba4f5da75852 Mon Sep 17 00:00:00 2001 From: Florrie Date: Wed, 25 Jul 2018 13:26:14 -0300 Subject: Hook menu up to grouplike listing items --- ui.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 7dbb05b..afb2731 100644 --- a/ui.js +++ b/ui.js @@ -123,6 +123,7 @@ class AppElement extends FocusElement { grouplikeListing.on('queue', item => this.queueGrouplikeItem(item)) grouplikeListing.on('queue (shuffled)', item => this.shuffleQueueGrouplikeItem(item)) grouplikeListing.on('queue (play next)', item => this.queueGrouplikeItem(item, true, this.playingTrack)) + grouplikeListing.on('menu', (item, opts) => this.menu.show(opts)) const updateListingsFor = item => { for (const grouplikeListing of this.tabber.tabberElements) { @@ -358,16 +359,6 @@ class AppElement extends FocusElement { this.tabber.nextTab() } else if (this.tabber.isSelected && keyBuf.equals(Buffer.from(['T'.charCodeAt(0)]))) { this.tabber.previousTab() - } else if (telc.isCharacter(keyBuf, 'm')) { - this.menu.show({ - x: this.w - 10, y: this.h + 30, - items: [ - 'Nice.', - 'Oh yeah.', - 'Ooooh yeah.', - 'N' + 'i'.repeat(200) + 'ce.' - ] - }) } else { super.keyPressed(keyBuf) } @@ -780,8 +771,8 @@ class GrouplikeListingElement extends FocusElement { if (this.grouplike.items.length) { for (const item of this.grouplike.items) { const itemElement = new GrouplikeItemElement(item, this.recordStore) - for (const evtName of ['download', 'remove (backspace)', 'remove (x)', 'mark', 'select (space)', 'select (enter)', 'queue', 'queue (shuffled)', 'queue (play next)']) { - itemElement.on(evtName, () => this.emit(evtName, item)) + for (const evtName of ['download', 'remove (backspace)', 'remove (x)', 'mark', 'select (space)', 'select (enter)', 'queue', 'queue (shuffled)', 'queue (play next)', 'menu']) { + itemElement.on(evtName, (...data) => this.emit(evtName, item, ...data)) } form.addInput(itemElement) } @@ -964,8 +955,20 @@ class GrouplikeItemElement extends Button { this.emit('remove (backspace)') } else if (telc.isCaselessLetter(keyBuf, 'x')) { this.emit('remove (x)') + /* } else if (telc.isCaselessLetter(keyBuf, 'm')) { this.emit('mark') + */ + } else if (telc.isCaselessLetter(keyBuf, 'm')) { + this.emit('menu', { + x: this.absLeft, + y: this.absTop + 1, + items: [ + 'Play', + 'Play next', + 'Play at end', + ] + }) } } } -- cgit 1.3.0-6-gf8a5