« get me outta code hell

Reset keyboard selector value when menu opens - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-04-11 21:26:38 -0300
committerFlorrie <towerofnix@gmail.com>2019-04-11 21:26:38 -0300
commit68fce2031ce323b57a20998d718f8f81026f0e4b (patch)
treee30ea374ee6e5d5586811476fe6491699f1e664d
parent2d10be31973a146b5039b3804fac2acf22955b15 (diff)
Reset keyboard selector value when menu opens
Otherwise you could type, for example, P to select "process...", then
close the menu, then reopen it and press R to jump to "remove...", but
it would just select "process" again because that matches "PR".
-rw-r--r--ui.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index ba60ca0..e9128a3 100644
--- a/ui.js
+++ b/ui.js
@@ -2287,6 +2287,8 @@ class ContextMenu extends FocusElement {
     this.fixLayout()
 
     this.form.firstInput()
+
+    this.keyboardSelector.reset()
   }
 
   keyPressed(keyBuf) {
@@ -2397,6 +2399,10 @@ class KeyboardSelector {
     this.form = form
   }
 
+  reset() {
+    this.value = ''
+  }
+
   keyPressed(keyBuf) {
     // Don't do anything if the input isn't a single keyboard character.
     if (keyBuf.length !== 1 || keyBuf[0] <= 31 || keyBuf[0] >= 127) {