« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js28
1 files changed, 17 insertions, 11 deletions
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()