class MaxobjListener
A listener for changes in a Maxobj object.
The MaxobjListener object listens for changes to a Maxobj object's value, or changes to a specified attribute of a Maxobj object. When a change occurs, a user-specified function will be called. The object also provides methods for getting and setting the value of the observed value or attribute.
For convenience, the MaxobjListener object is a property of the MaxobjListenerData argument passed to the callback function. To access the ParameterListener from within its function, use MaxobjListenerData.listener.
Example
function valuechanged(data) {
post("value changed!\n");
if (data.attrname) {
post("attrname: " + data.attrname + "\n");
}
post("new value: " + data.value + "\n");
}
var ob = this.patcher.getnamed("someobject");
var l = new MaxobjListener(ob, "patching_rect", valuechanged);
Index
Constructors
Properties
Methods
new MaxobjListener(object, fn)
new MaxobjListener(object: Maxobj, fn: Function);
Constructs a new instance of the MaxobjListener class
Without an attribute name provided, the listener will observe the value of the object itself. Not every Max object has an observable value -- objects compatible with the pattr family of Max objects can be observed in this fashion. Practically, that means nearly every UI object as well as a handful of normal Max box objects (including js, pattr and dict). Attributes can be observed for any Maxobj which has attributes.
| Parameter | Type | Description |
|---|---|---|
| object | Maxobj | the object to attach a listener to |
| fn | Function | the callback function which takes a MaxobjListenerData as an argument |
new MaxobjListener(object, attrName, fn)
new MaxobjListener(object: Maxobj, attrName: string, fn: Function);
Create a MaxobjListener that observes a specific attribute
| Parameter | Type | Description |
|---|---|---|
| object | Maxobj | the object to attach a listener to |
| attrName | string | the attribute to listen to |
| fn | Function | the callback function which takes a MaxobjListenerData as an argument |
attrname string read-only
An attribute to observe for changes, if desired
getvalue()
Get the value of the Maxobj or its specified attribute
getvalue(): number | number[] | string;
| Name | Type | Description |
|---|---|---|
| Return Value | number | number[] | string |
maxobject Maxobj read-only
The Maxobj to observe
setvalue(value)
Set the value of the Maxobj or its specified attribute
setvalue(value: any): void;
| Name | Type | Description |
|---|---|---|
| value | any | the new value |
setvalue_silent(value)
Set the value of a the Maxobj or its specified attribute, but don't execute the callback function
setvalue_silent(value: number): void;
| Name | Type | Description |
|---|---|---|
| value | number | the new value |
silent number
Whether to execute the callback function in response to calling MaxobjListener.setvalue() from this MaxobjListener