events/change: pass widget instance instead of widget $dom element in the event and fix switcher error when editing (undefined widget reference in "change" event data
This commit is contained in:
parent
3914ffead9
commit
d7979ee44e
15 changed files with 25 additions and 25 deletions
|
|
@ -22,9 +22,9 @@ var WidgetManager = function(){
|
|||
// Widget that share the same id will update each other
|
||||
// without sending any extra osc message
|
||||
if (widgetsById.length>1) {
|
||||
var v = widget.abstract.getValue()
|
||||
var v = widget.getValue()
|
||||
for (let i in widgetsById) {
|
||||
if (widgetsById[i].hash != widget.abstract.hash && widgetsById[i].setValue) {
|
||||
if (widgetsById[i].hash != widget.hash && widgetsById[i].setValue) {
|
||||
widgetsById[i].setValue(v,{send:false,sync:false})
|
||||
}
|
||||
}
|
||||
|
|
@ -33,9 +33,9 @@ var WidgetManager = function(){
|
|||
// widgets that share the same linkId will update each other.
|
||||
// Updated widgets will send osc messages normally
|
||||
if (widgetsByLinkId.length>1) {
|
||||
var v = widget.abstract.getValue()
|
||||
var v = widget.getValue()
|
||||
for (let i in widgetsByLinkId) {
|
||||
if (widgetsByLinkId[i].hash != widget.abstract.hash && widgetsByLinkId[i].setValue) {
|
||||
if (widgetsByLinkId[i].hash != widget.hash && widgetsByLinkId[i].setValue) {
|
||||
widgetsByLinkId[i].setValue(v,{send:options.send,sync:false})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,12 +65,12 @@ module.exports = class Dropdown extends _widgets_base {
|
|||
this.value = this.values[i]
|
||||
if (!options.fromLocal) this.select[0].selectedIndex = i
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options})
|
||||
this.container.removeClass('noselect')
|
||||
} else {
|
||||
this.value = undefined
|
||||
this.select[0].selectedIndex = -1
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options})
|
||||
this.container.addClass('noselect')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,14 +85,14 @@ module.exports = class Push extends _widgets_base {
|
|||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
if (options.send) this.sendValue(v)
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
|
||||
this.widget.removeClass('active')
|
||||
this.active = 0
|
||||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
if (options.send) this.sendValue(v, this.getProp('norelease'))
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -109,13 +109,13 @@ module.exports = class Push extends _widgets_base {
|
|||
this.state = 1
|
||||
if (options.send) this.sendValue(v)
|
||||
this.lastChanged = 'state'
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'),options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'),options:options})
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
|
||||
this.classHolders.removeClass('on')
|
||||
this.state = 0
|
||||
if (options.send) this.sendValue(v)
|
||||
this.lastChanged = 'state'
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'),options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'),options:options})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ module.exports = class Switch extends _widgets_base {
|
|||
this.widget.find('.on').removeClass('on')
|
||||
this.widget.find('.value').eq(i).addClass('on')
|
||||
if (options.send) this.sendValue(this.value)
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options})
|
||||
} else {
|
||||
this.widget.find('.on').removeClass('on')
|
||||
this.value = undefined
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options})
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ module.exports = class Toggle extends _widgets_base {
|
|||
if (options.send) this.sendValue()
|
||||
}
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ module.exports = class Modal extends Panel {
|
|||
if (!this.init && this.value) this.init = true
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.light.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
if (options.sync) this.light.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ module.exports = class Panel extends _widgets_base {
|
|||
}
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options})
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ module.exports = class Input extends _canvas_base {
|
|||
}
|
||||
}
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
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()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module.exports = class _matrices_base extends _widgets_base {
|
|||
|
||||
if (e.id==this.getProp('id')) return
|
||||
this.value[e.widget.parent().index()] = e.widget.abstract.getValue()
|
||||
this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget,options:e.options})
|
||||
this.widget.trigger({type:'change',id:this.getProp('id'),widget:this,options:e.options})
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
}
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'change', id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change', id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
this.value = v
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'change', id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change', id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
|
||||
this.update({dragged:options.dragged, nohue:options.nohue || (v[0]==v[1]&&v[1]==v[2])})
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ module.exports = class Xy extends _pads_base {
|
|||
]
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'change', id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change', id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
|
||||
this.draw()
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
this.showValue()
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.send) this.sendValue()
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
if (options.sync && match) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync && match) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.send && match && !(!this.getProp('snap') && options.draginit)) this.sendValue()
|
||||
|
||||
if (options.dragged || options.draginit) this.updateDisplay(options.draginit)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ module.exports = class _switchers_base extends _widgets_base {
|
|||
|
||||
var {id, widget} = e
|
||||
|
||||
if (this.value._selected !== false && this.value[this.value._selected] && widget.abstract._isSwitcher !== true && this.isWatching(id, widget)) {
|
||||
if (widget && this.value._selected !== false && this.value[this.value._selected] && widget._isSwitcher !== true && this.isWatching(id, widget)) {
|
||||
|
||||
this.value[this.value._selected][id] = widget.abstract.getValue()
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ module.exports = class _switchers_base extends _widgets_base {
|
|||
|
||||
for (var i in widgets) {
|
||||
|
||||
if (widgets[i].widget[0].contains(widget[0])) return true
|
||||
if (widgets[i].widget[0].contains(widget.widget[0])) return true
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ module.exports = class _switchers_base extends _widgets_base {
|
|||
}
|
||||
}
|
||||
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this.widget, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.sync) this.widget.trigger({type:'change',id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
if (options.send) this.sendValue()
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue