From 39d4ec4d0de41c7f99a3b91a3128b6f3b5e8d3fc Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 14 Dec 2021 08:34:11 -0400 Subject: right click InlineListPickerElement to show menu This menu was already implemented, but previously, it only showed when pressing F (i.e. isMenu). --- ui.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 6d07f2b..18652f5 100644 --- a/ui.js +++ b/ui.js @@ -3245,17 +3245,7 @@ class InlineListPickerElement extends FocusElement { } else if (telc.isLeft(keyBuf)) { this.previousOption() } else if (input.isMenu(keyBuf) && this.showContextMenu) { - this.showContextMenu({ - x: this.absLeft + ansi.measureColumns(this.labelText) + 1, - y: this.absTop + 1, - items: this.options.map(({ value, label }, index) => ({ - label: label, - action: () => { - this.curIndex = index - }, - isDefault: index === this.curIndex - })) - }) + this.showMenu() } else { return true } @@ -3269,6 +3259,8 @@ class InlineListPickerElement extends FocusElement { } else { this.root.select(this) } + } else if (button === 'right') { + this.showMenu() } else if (button === 'scroll-up') { this.previousOption() } else if (button === 'scroll-down') { @@ -3280,6 +3272,20 @@ class InlineListPickerElement extends FocusElement { } + showMenu() { + this.showContextMenu({ + x: this.absLeft + ansi.measureColumns(this.labelText) + 1, + y: this.absTop + 1, + items: this.options.map(({ value, label }, index) => ({ + label: label, + action: () => { + this.curIndex = index + }, + isDefault: index === this.curIndex + })) + }) + } + refreshValue() { if (this.getValue) { const value = this.getValue() -- cgit 1.3.0-6-gf8a5