« get me outta code hell

right click InlineListPickerElement to show menu - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2021-12-14 08:34:11 -0400
committer(quasar) nebula <qznebula@protonmail.com>2021-12-14 08:34:11 -0400
commit39d4ec4d0de41c7f99a3b91a3128b6f3b5e8d3fc (patch)
tree06056180942b3f4f82786f4d474cbc90f7f32395
parent7828f9cfded16432e48e6c141c824f54c259048b (diff)
right click InlineListPickerElement to show menu
This menu was already implemented, but previously, it only showed when
pressing F (i.e. isMenu).
-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()