input: various fixes

This commit is contained in:
jean-emmanuel 2017-07-26 17:25:42 +02:00
parent 6b13d74971
commit 7c74ddd0ad
3 changed files with 13 additions and 36 deletions

View file

@ -54,7 +54,6 @@ module.exports = class Input extends _canvas_base {
this.value = ''
this.stringValue = ''
if (this.getProp('editable')) {
this.canvas.on('focus', this.focus.bind(this))
@ -111,21 +110,14 @@ module.exports = class Input extends _canvas_base {
syncHandle(e) {
if (this.getProp('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length) return
if (this.getProp('widgetId')!=e.id || !widgetManager.getWidgetById(e.id).length || !e.widget) return
var widget = widgetManager.getWidgetById(e.id),
value
for (var i=widget.length-1; i>=0; i--) {
if (widget[i].getValue) {
this.setValue(widget[i].getValue(), {...e.options, fromSync:true})
return
}
}
this.setValue(e.widget.getValue(), {...e.options, internal:true})
}
resizeHandle(){
super.resizeHandle(...arguments)
if (this.getProp('horizontal')){
@ -149,19 +141,20 @@ module.exports = class Input extends _canvas_base {
this.value = v
}
this.stringValue = this.getStringValue()
this.draw()
if (this.getProp('widgetId').length && !options.fromSync) {
if (!options.internal && this.getProp('widgetId').length) {
var widget = widgetManager.getWidgetById(this.getProp('widgetId'))
options.hash = this.hash
for (var i=widget.length-1; i>=0; i--) {
if (widget[i].setValue) {
widget[i].setValue(this.value, options)
this.setValue(widget[i].getValue(), {...options, internal:true})
return
}
}
}
this.stringValue = this.getStringValue()
this.draw()
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
if (options.send && !options.fromSync) this.sendValue()
@ -173,7 +166,7 @@ module.exports = class Input extends _canvas_base {
width = this.getProp('horizontal') ? this.height : this.width,
height = !this.getProp('horizontal') ? this.height : this.width
if (this.getProp('unit')) v += ' ' + this.getProp('unit')
if (this.getProp('unit') && v.length) v += ' ' + this.getProp('unit')
this.clear()

View file

@ -38,7 +38,9 @@
vertical-align: top;
// font-weight: bold;
letter-spacing: 1rem;
&:focus {
color:var(--color-custom);
}
}
canvas {
height: 100%;
@ -50,10 +52,7 @@
display: none;
}
&:focus {
color:var(--color-accent);
}
}
}