« get me outta code hell

Add 'cancel' event (on ESC) to TextInput - 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
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-09-12 14:09:46 -0300
committerFlorrie <towerofnix@gmail.com>2018-09-12 14:09:46 -0300
commit9bffe0da811c4ff445348531f66db1559d80fd2d (patch)
tree2b1957543eef4bd3b338e20ec751e077a37e1792 /ui
parenta4020ad79c4c9f275c960882bfec8bb473d98d9f (diff)
Add 'cancel' event (on ESC) to TextInput
Diffstat (limited to 'ui')
-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 f07b562..766f959 100644
--- a/ui/form/TextInput.js
+++ b/ui/form/TextInput.js
@@ -68,6 +68,9 @@ module.exports = class TextInput extends FocusElement {
       }
     } else if (telc.isEscape(keyBuf)) {
       // ESC is bad and we don't want that in the text input!
+      // Also emit a "cancel" event, which doesn't necessarily do anything,
+      // but can be listened to.
+      this.emit('cancel')
       return
     } else {
       const isTextInput = keyBuf.toString().split('').every(chr => {