MaxobjListener callback called for every attribute when 'null' is provided for attribute name?
Jun 03 2021 | 12:47 am
I'm trying to make a Maxobjlistener that changes the color of the observed object when it's value changes. This is creating an infinite loop of MaxobjListener callbacks. But per the MaxobjListener documentation:
"If the attribute_name argument is specified, the MaxobjListener object will observe that named attribute. Otherwise the object's value will be observed."
Am I doing this wrong, or is this a bug?
Some example code is like this:
function valuechanged(data) {
var v = data.value * 0.01
post(v, "\n") // view console spew
data.listener.maxobject.setattr("bgcolor", [0.5, v, v, 1.])
outlet(0, "bang")
}
// a numbox
var mxobj = this.patcher.getnamed("color")
// listen to value changes of the numbox
var listener = new MaxobjListener( mxobj, null, valuechanged )