editor: validate property change when clicking on a widget; cancel property change when hitting escape
This commit is contained in:
parent
f324296a40
commit
89b594dfaa
3 changed files with 27 additions and 16 deletions
|
|
@ -76,12 +76,9 @@ class UiInspector extends UiWidget {
|
|||
})
|
||||
|
||||
|
||||
this.container.addEventListener('blur', this.onBlur.bind(this))
|
||||
this.container.addEventListener('change', this.onChange.bind(this))
|
||||
this.container.addEventListener('keydown', this.onKeydown.bind(this))
|
||||
this.container.addEventListener('input', this.onFocus.bind(this))
|
||||
this.container.addEventListener('focus', this.onFocus.bind(this))
|
||||
|
||||
this.container.addEventListener('input', this.onInput.bind(this))
|
||||
|
||||
this.lock = false
|
||||
this.clearTimeout = null
|
||||
|
|
@ -207,7 +204,9 @@ class UiInspector extends UiWidget {
|
|||
|
||||
this.lock = true
|
||||
|
||||
var input = event ? event.target : this.focusedInput
|
||||
var input = this.focusedInput || event.target
|
||||
|
||||
this.focusedInput = null
|
||||
|
||||
input.blur()
|
||||
|
||||
|
|
@ -235,14 +234,26 @@ class UiInspector extends UiWidget {
|
|||
|
||||
onKeydown(event) {
|
||||
|
||||
if (this.focusedInput && event.keyCode === 13 && !event.shiftKey) {
|
||||
event.preventDefault()
|
||||
DOM.dispatchEvent(this.focusedInput, 'change')
|
||||
if (event.target.tagName === 'TEXTAREA') {
|
||||
|
||||
if (event.keyCode === 13 && !event.shiftKey) {
|
||||
|
||||
event.preventDefault()
|
||||
DOM.dispatchEvent(event.target, 'change')
|
||||
|
||||
} else if (event.keyCode === 27) {
|
||||
|
||||
event.preventDefault()
|
||||
event.target.value = event.target.textContent
|
||||
event.target.blur()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onFocus(event) {
|
||||
onInput(event) {
|
||||
|
||||
this.focusedInput = event.target
|
||||
|
||||
|
|
@ -253,12 +264,6 @@ class UiInspector extends UiWidget {
|
|||
|
||||
}
|
||||
|
||||
onBlur(event) {
|
||||
|
||||
this.focusedInput = null
|
||||
|
||||
}
|
||||
|
||||
help(name) {
|
||||
|
||||
var defaultValue = defaults[this.widget.getProp('type')][name],
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class Script extends Widget {
|
|||
shift: false,
|
||||
alt: false,
|
||||
meta: false,
|
||||
)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue