class Maxobj
A JavaScript representation of a Max object in a patcher.
Perhaps the most powerful thing about a Maxobj is that you can send any message to a Maxobj that you can send to a Max object. For example, if you had a number box Maxobj and you wanted to set its value to 23 without outputting the value, you could do this:
n.set(23);
Note that certain words such as int, float, and delete are keywords in JavaScript, and you will need to use either array notation or the message method for such reserved words. For example:
n.message("int", 23);
n["int"](23);
Index
Constructors
Properties
- background
- boxtext
- canhilite
- colorindex
- hidden
- ignoreclick
- js
- maxclass
- nextobject
- patchcords
- patcher
- rect
- selected
- valid
- varname
Methods
- attrname_forstylemap(mapname)
- getattr(attrName)
- getattrattr(attrName, attrAttrName)
- getattrnames()
- getboxattr(attrName)
- getboxattrattr(attrName, attrAttrName)
- getboxattrnames()
- getvalueof()
- help()
- message(message, args)
- setattr(attrName, value)
- setattrdefault(attrName)
- setboxattr(attrName, value)
- setboxattrdefault(attrName)
- setvalueof(args)
- subpatcher(index)
- understands(message)
new Maxobj() protected
protected new Maxobj();
You cannot create a Maxobj directly. Instances are obtained from Patcher properties and methods like Patcher.newdefault() or Patcher.getnamed().
attrname_forstylemap(mapname)
Get the attribute name corresponding to a style mapping name
attrname_forstylemap(mapname: string): string;
| Name | Type | Description |
|---|---|---|
| mapname | string | the style map name |
| Return Value | string | the attribute name for the given style map name |
background boolean
Whether the object is in the patchers background layer
boxtext string read-only
Supported only in the v8 engine.
The text contained in the object box (if present)
canhilite boolean read-only
Whether the object can be selected for text entry
A number box would be one example of an object which would return true
colorindex number
Deprecated
The standard 16-color palette is a legacy feature; use the object's color attribute instead.
If the object is set to use one of the standard 16 colors, the index of the color
getattr(attrName)
Get the value of an attribute
getattr(attrName: string): number | number[] | string;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
| Return Value | number | number[] | string |
getattrattr(attrName, attrAttrName)
Supported only in the v8 engine.
Get the value of an attribute's attribute
getattrattr(
attrName: string,
attrAttrName: string,
): number | number[] | string;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
| attrAttrName | string | the attribute name |
| Return Value | number | number[] | string |
getattrnames()
Get all available attributes for the object
getattrnames(): string[];
| Name | Type | Description |
|---|---|---|
| Return Value | string[] |
getboxattr(attrName)
Get the value of the object's box attribute
getboxattr(attrName: string): number | number[] | string;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
| Return Value | number | number[] | string |
getboxattrattr(attrName, attrAttrName)
Supported only in the v8 engine.
Get the value of the object's box attribute's attribute
getboxattrattr(
attrName: string,
attrAttrName: string,
): number | number[] | string;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
| attrAttrName | string | the attribute name |
| Return Value | number | number[] | string |
getboxattrnames()
Get the names of all available attributes for the object's box
getboxattrnames(): string[];
| Name | Type | Description |
|---|---|---|
| Return Value | string[] |
getvalueof()
Get the current value of the object, if supported
getvalueof(): any;
| Name | Type | Description |
|---|---|---|
| Return Value | any | the object's current value |
help()
Open a help file describing an object, if it exists
help(): void;
hidden boolean
Whether the object is hidden in a locked patcher
ignoreclick boolean
Whether the object ignores clicks
js object read-only
If the Maxobj refers to an object that is a js Max class, this returns the associated jsthis object
This property is only available in the legacy js javascript engine objects.
maxclass string read-only
The Max class
This is different from the JavaScript class ("Maxobj") which is accessed via the standard class property.
message(message, args)
Send the object a message with any additional arguments
This is useful for sending messages to objects which dynamically dispatch messages with the anything message like js, jsui, lcd, and others.
message(message: string, ...args: any[]): void;
| Name | Type | Description |
|---|---|---|
| message | string | the message to send |
| args | any[] | any arguments for the message |
nextobject Maxobj | undefined read-only
The next object in the patcher's list of objects, otherwise nil
patchcords object read-only
An object containing two arrays, inputs, and outputs, each of which may contain MaxobjConnection objects
patcher Patcher read-only
The Patcher object that contains the Maxobj
rect [number, number, number, number]
The location of an object in a patcher (left, top, right, bottom)
When the object's rectangle is changed, it will move on screen if it's visible.
selected boolean
Whether the object is selected in an unlocked patcher window
setattr(attrName, value)
Set the value of an attribute
setattr(attrName: string, value: number | number[] | string): void;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
| value | number | number[] | string | the new attribute value |
setattrdefault(attrName)
Supported only in the v8 engine.
Set the value of an attribute to its default value (if a default value is defined)
setattrdefault(attrName: string): void;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
setboxattr(attrName, value)
Set the value of a box attribute
setboxattr(attrName: string, value: number | number[] | string): void;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
| value | number | number[] | string | the new attribute value |
setboxattrdefault(attrName)
Supported only in the v8 engine.
Set the value of the object's box attribute to its default value (if a default value is defined)
setboxattrdefault(attrName: string): void;
| Name | Type | Description |
|---|---|---|
| attrName | string | the attribute name |
setvalueof(args)
Set the value of the object, if supported
setvalueof(...args: any[]): void;
| Name | Type | Description |
|---|---|---|
| args | any[] | the value(s) to set |
subpatcher(index)
If the object contains a patcher, returns a Patcher, otherwise nil
subpatcher(index?: number): Patcher | undefined;
| Name | Type | Description |
|---|---|---|
| optional index | number | an instance number (only used with poly~) |
| Return Value | Patcher | undefined |
understands(message)
Get whether the object has an entry in its message list for a given string
If the entry is not a message that can be sent by a user within Max (i.e. it's a C-level "untyped" message), false is returned. This doesn't work for messages which are dynamically dispatched with the anything message, as is the case for instances of js, jsui, lcd, and others.
understands(message: string): boolean;
| Name | Type | Description |
|---|---|---|
| message | string | an object message |
| Return Value | boolean |
valid boolean read-only
Whether the Maxobj refers to a valid Max object
A Maxobj could eventually refer to an object that no longer exists if the underlying Max object is freed. The valid property can be used to test for this condition.
varname string
The patcher-specific name of the object as set in the inspector or via the Object > Name... menu option