Last modified: 2012-12-5
Class Maxobj
A Maxobj is a Javascript representation of a Max object in a patcher.
It is returned by various methods of a Javascript Patcher object, such as newobject()
.
One important thing to keep in mind about a Maxobj is that it 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.
Maxobj in Cycling '74 Reference
Constructor Attributes | Constructor Name and Description |
---|---|
Maxobj()
Create with
patcher.newdefault() or patcher.newobject() . |
Field Attributes | Field Name and Description |
---|---|
Boolean get/set |
Whether the object is in the Patcher's background layer.
|
Boolean get |
Whether the object can be selected for text entry.
|
Number get/set |
If the object is set to use one of the standard 16 colors, this property is the index of the color.
|
Integer |
Sets the type style used by the object.
|
String |
Sets the object's font.
|
Float |
Sets the object's font size (in points)
|
Boolean get/set |
Is the object set to be hidden in a locked patcher?.
|
String |
Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.
|
Boolean get/set |
Whether the object ignores clicks.
|
jsthis get |
If the Maxobj refers to an object is of Max class js, this returns the associated jsthis object.
|
String get |
The Max class (as opposed to the Javascript class, which is "Maxobj" and accessed
via the standard class property) of the object.
|
Maxobj get |
If there is another object after this one in the Patcher's list of objects,
this property returns it, otherwise it returns a nil value.
|
Patcher get |
The Patcher object that contains the Maxobj.
|
Array get/set |
The location of an object in a patcher.
|
Boolean get/set |
Whether the object is selected in an unlocked patcher window.
|
Boolean get |
Returns whether the Maxobj refers to a valid Max object.
|
String get/set |
The patcher-specific name of the object, as set with the Name dialog.
|
Method Attributes | Method Name and Description |
---|---|
void |
annotation(text)
Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.
|
void |
color(rgba)
Sets the color for the object box outline.
|
void |
help()
Opens a help file describing the object, if it exists.
|
void |
message(mixed)
Sends the object the message specified by the string, followed by any additional arguments provided.
|
void |
notify()
|
Patcher Array |
If the object contains a patcher, this function returns a (Javascript) Patcher object.
|
Boolean |
understands(name)
Returns a Boolean value if the object has an entry in its message list for the message specified by the string.
|
Class Detail
Maxobj
()
Create with
patcher.newdefault()
or patcher.newobject()
.
- Example:
//TODO here comes a bigger example of usage in context
Field Detail
{Boolean get/set}
background
Whether the object is in the Patcher's background layer.
- Example:
//TODO here comes small example code
{Boolean get}
canhilite
Whether the object can be selected for text entry.
(a number box would be an example of an object whose canhilite property returns true)
- Example:
//TODO here comes small example code
{Number get/set}
colorindex
If the object is set to use one of the standard 16 colors, this property is the index of the color.
- Example:
//TODO here comes small example code
{Integer}
fontface
Sets the type style used by the object. The options are:
plain, bold, italic, bold italic, regular
plain, bold, italic, bold italic, regular
{String}
fontname
Sets the object's font.
{Float}
fontsize
Sets the object's font size (in points)
{Boolean get/set}
hidden
Is the object set to be hidden in a locked patcher?.
- Example:
//TODO here comes small example code
{String}
hint
Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.
{Boolean get/set}
ignoreclick
Whether the object ignores clicks.
- Example:
//TODO here comes small example code
{jsthis get}
js
If the Maxobj refers to an object is of Max class js, this returns the associated jsthis object.
- Example:
//TODO here comes small example code
{String get}
maxclass
The Max class (as opposed to the Javascript class, which is "Maxobj" and accessed
via the standard class property) of the object.
- Example:
//TODO here comes small example code
{Maxobj get}
nextobject
If there is another object after this one in the Patcher's list of objects,
this property returns it, otherwise it returns a nil value.
- Example:
//TODO here comes small example code
{Patcher get}
patcher
The Patcher object that contains the Maxobj.
- Example:
//TODO here comes small example code
{Array get/set}
rect
The location of an object in a patcher. When the object's rectangle is changed,
it will move on screen if it is visible. The coordinates are stored in the
following order: left, top, right, bottom.
- Example:
//TODO here comes small example code
{Boolean get/set}
selected
Whether the object is selected in an unlocked patcher window.
- Example:
//TODO here comes small example code
{Boolean get}
valid
Returns whether the Maxobj refers to a valid Max object.
- Example:
//TODO here comes small example code
{String get/set}
varname
The patcher-specific name of the object, as set with the Name dialog.
- Example:
//TODO here comes small example code
Method Detail
{void}
annotation
(text)
Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.
- Parameters:
- {String} text
- Returns:
- void
{void}
color
(rgba)
Sets the color for the object box outline.
- Parameters:
- {Array} rgba
- RGBA Color
- Returns:
- void
{void}
help
()
Opens a help file describing the object, if it exists.
- Example:
//TODO here comes small example code
- Returns:
- void
{void}
message
(mixed)
Sends the object the message specified by the string, followed by any additional arguments provided. This is useful for sending messages to object which dynamically dispatch messages with the “anything” message, as is the case for instances of js, jsui, lcd, and others.
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 in Max as if you were invoking a method on the object in Javascript. 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:
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.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:
- Example:
n.message("int", 23); //or n["int"](23);
- Parameters:
- {mixed [...]} mixed
- can be anything, a string, an array, a list
- Returns:
- void
{void}
notify
()
{Patcher Array}
subpatcher
()
If the object contains a patcher, this function returns a (Javascript) Patcher object. The optional index is used for specifying an instance number, which only applies to poly~ objects. If the object does not contain a subpatcher, a nil value is returned.
- Example:
//TODO here comes small example code
- Returns:
- Patcher Array
{Boolean}
understands
(name)
Returns a Boolean value if the object has an entry in its message list for the message specified by the 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.
- Example:
//TODO here comes small example code
- Parameters:
- {String} name
- Messagename or property to test
- Returns:
- Boolean