« get me outta code hell

ListScrollForm - don't bubble key presses - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/ui/form
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-06-04 09:57:08 -0300
committerFlorrie <towerofnix@gmail.com>2018-06-04 09:57:11 -0300
commit01707d9e6376ff04a7b39381eb6b131717a721fe (patch)
tree660e42ab3c8f07a5fbd4baf3abeb974505c83513 /ui/form
parenteae9716c237ad7c9602cc05f6babc6c2714e258c (diff)
ListScrollForm - don't bubble key presses
E.g. if up is pressed in a ListScrollForm, don't tell the parent element
that up was pressed.
Diffstat (limited to 'ui/form')
-rw-r--r--ui/form/ListScrollForm.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js
index dcdb562..581c82f 100644
--- a/ui/form/ListScrollForm.js
+++ b/ui/form/ListScrollForm.js
@@ -52,37 +52,41 @@ module.exports = class ListScrollForm extends Form {
   }
 
   keyPressed(keyBuf) {
+    let ret
+
     handleKeyPress: {
       if (this.layoutType === 'horizontal') {
         if (telc.isLeft(keyBuf)) {
           this.previousInput()
-          break handleKeyPress
+          ret = false; break handleKeyPress
         } else if (telc.isRight(keyBuf)) {
           this.nextInput()
-          break handleKeyPress
+          ret = false; break handleKeyPress
         }
       } else if (this.layoutType === 'vertical') {
         if (telc.isUp(keyBuf)) {
           this.previousInput()
-          break handleKeyPress
+          ret = false; break handleKeyPress
         } else if (telc.isDown(keyBuf)) {
           this.nextInput()
-          break handleKeyPress
+          ret = false; break handleKeyPress
         }
       }
 
       if (telc.isPageUp(keyBuf)) {
         this.previousPage()
-        break handleKeyPress
+        ret = false; break handleKeyPress
       } else if (telc.isPageDown(keyBuf)) {
         this.nextPage()
-        break handleKeyPress
+        ret = false; break handleKeyPress
       }
 
-      super.keyPressed(keyBuf)
+      ret = super.keyPressed(keyBuf)
     }
 
     this.scrollSelectedElementIntoView()
+
+    return ret
   }
 
   scrollSelectedElementIntoView() {