« get me outta code hell

Add TextInput events: confirm (= value), change - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-09-13 21:52:18 -0300
committerFlorrie <towerofnix@gmail.com>2018-09-13 21:52:18 -0300
commitcaf3398a3029bc852545ddd5f6584fb9cf3a4929 (patch)
tree574f05451add531f96266b773748cfc2a7aa8adc
parente2f830680c1a6e9f28ad305b105caf5cdf092e63 (diff)
Add TextInput events: confirm (= value), change
-rw-r--r--ui/form/TextInput.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/ui/form/TextInput.js b/ui/form/TextInput.js
index 5b5fa06..08bbbb6 100644
--- a/ui/form/TextInput.js
+++ b/ui/form/TextInput.js
@@ -58,7 +58,9 @@ module.exports = class TextInput extends FocusElement {
         this.root.cursorMoved()
         return false
       } else if (keyBuf[0] === 13) {
+        // These are aliases for each other.
         this.emit('value', this.value)
+        this.emit('confirm', this.value)
       } else if (keyBuf[0] === 0x1b && keyBuf[1] === 0x5b) {
         // Keyboard navigation
         if (keyBuf[2] === 0x44) {
@@ -87,6 +89,7 @@ module.exports = class TextInput extends FocusElement {
           )
           this.cursorIndex += keyBuf.toString().length
           this.root.cursorMoved()
+          this.emit('change', this.value)
 
           return false
         }