input: add asYouType option (#561)
This commit is contained in:
parent
b332cae3a5
commit
46a86f8870
2 changed files with 10 additions and 2 deletions
|
|
@ -5,7 +5,8 @@
|
|||
- widgets
|
||||
- frames: allow loading local html files without requiring a web server to serve them
|
||||
- text: escape html tags characters (`<` & `>`)
|
||||
|
||||
- input: added `asYouType` property
|
||||
|
||||
## 0.47.4
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ module.exports = class Input extends Canvas {
|
|||
vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'},
|
||||
align: {type: 'string', value: '', help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
|
||||
unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'},
|
||||
editable: {type: 'boolean', value: true, help: 'Set to `false` to make the input non-editable'}
|
||||
editable: {type: 'boolean', value: true, help: 'Set to `false` to make the input non-editable'},
|
||||
asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'}
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -51,10 +52,16 @@ module.exports = class Input extends Canvas {
|
|||
this.blur(this.tabKeyBlur)
|
||||
this.tabKeyBlur = false
|
||||
})
|
||||
var asYouType = this.getProp('asYouType')
|
||||
this.input.addEventListener('keydown', (e)=>{
|
||||
if (e.keyCode === 13) this.blur() // enter
|
||||
else if (e.keyCode === 27) this.blur(false) // esc
|
||||
else if (e.keyCode === 9) this.tabKeyBlur = true // tab
|
||||
else if (asYouType) {
|
||||
setTimeout(()=>{
|
||||
this.inputChange()
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.widget.classList.add('not-editable')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue