diff options
Diffstat (limited to 'ui/form')
-rw-r--r-- | ui/form/TextInput.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/ui/form/TextInput.js b/ui/form/TextInput.js index 11e4060..f07b562 100644 --- a/ui/form/TextInput.js +++ b/ui/form/TextInput.js @@ -70,13 +70,22 @@ module.exports = class TextInput extends FocusElement { // ESC is bad and we don't want that in the text input! return } else { - // console.log(keyBuf, keyBuf[0], keyBuf[1], keyBuf[2]) - this.value = ( - this.value.slice(0, this.cursorIndex) + keyBuf.toString() + - this.value.slice(this.cursorIndex) - ) - this.cursorIndex++ - this.root.cursorMoved() + const isTextInput = keyBuf.toString().split('').every(chr => { + const n = chr.charCodeAt(0) + return n > 31 && n < 127 + }) + + if (isTextInput) { + this.value = ( + this.value.slice(0, this.cursorIndex) + keyBuf.toString() + + this.value.slice(this.cursorIndex) + ) + this.cursorIndex += keyBuf.toString().length + this.root.cursorMoved() + this.keepCursorInRange() + + return false + } } this.keepCursorInRange() |