<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet href="_c74_vig.xsl" type="text/xsl"?>
<vignette name="The Maxobj Object" package="Max">
<h1>The Maxobj Object</h1>
<p>
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.
</p>
<a name="maxobjectproperties" />
	<jsproperty_list name="Maxobj">
		<jsproperty name="rect" get="1" set="1" type="Array">
			<description>
				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.
        	</description>
    	</jsproperty>

		<jsproperty name="maxclass" get="get" set="0" type="String">
			<description>
				The Max class (as opposed to the Javascript class, which is "Maxobj" and accessed via the standard class property) of the object.
        	</description>
    	</jsproperty>

		<jsproperty name="patcher" get="1" set="0" type="object">
			<description>
				The Patcher object that contains the Maxobj
        	</description>
    	</jsproperty>

		<jsproperty name="hidden" get="1" set="1" type="Boolean">
			<description>
				Is the object set to be hidden in a locked patcher?
        	</description>
    	</jsproperty>

		<jsproperty name="colorindex" get="1" set="1" type="Number">
			<description>
				If the object is set to use one of the standard 16 colors, this property is the index of the color
        	</description>
    	</jsproperty>

		<jsproperty name="nextobject" get="get" set="0" type="object">
			<description>
				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
        	</description>
    	</jsproperty>

		<jsproperty name="varname" get="1" set="1" type="String">
			<description>
				The patcher-specific name of the object, as set with the Name... dialog
        	</description>
    	</jsproperty>

		<jsproperty name="canhilite" get="1" set="0" type="Boolean">
			<description>
				Whether the object can be selected for text entry (a number box would be an example of an object whose canhilite property returns true)
        	</description>
    	</jsproperty>

		<jsproperty name="background" get="1" set="1" type="Boolean">
			<description>
				Whether the object is in the Patcher's background layer
        	</description>
    	</jsproperty>

		<jsproperty name="ignoreclick" get="1" set="1" type="Boolean">
			<description>
				Whether the object ignores clicks
        	</description>
    	</jsproperty>

		<jsproperty name="selected" get="1" set="0" type="Boolean">
			<description>
				Whether the object is selected in an unlocked patcher window.
        	</description>
    	</jsproperty>

		<jsproperty name="js" get="1" set="0" type="object">
			<description>
				If the Maxobj refers to an object is of Max class js, this returns the associated <b>jsthis</b> object
        	</description>
    	</jsproperty>

		<jsproperty name="valid" get="1" set="0" type="Boolean">
			<description>
				Returns whether the Maxobj refers to a valid Max object
        	</description>
    	</jsproperty>
    </jsproperty_list>
<h2>Maxobj Methods Overview</h2>
<p>
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:
</p>
<code>
  n.set(23);
</code>
<p>
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:
</p>
<code>
  n.message("int", 23);
  //or
  n["int"](23);
</code>
<p>
The following methods are common to all Maxobj objects.
</p>
	<jsmethod_list name="Maxobj">
  		<jsmethod name="message">
		    <arglist>
		    	<arg name="message" type="string"/>
		    	<arg name="anything" type="string"/>
		    </arglist>
		    <description>
		    	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.
		    </description>
  		</jsmethod>
  		<jsmethod name="help">
		    <description>
		    	Opens a help file describing the object, if it exists
		    </description>
  		</jsmethod>

  		<jsmethod name="subpatcher">
		    <arglist>
		    	<arg name="index" type="number"/>
		    </arglist>
		    <description>
		    	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.
		    </description>
  		</jsmethod>

  		<jsmethod name="understands">
		    <arglist>
		    	<arg name="message" type="string"/>
		    </arglist>
		    <description>
		    	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.
		    </description>
  		</jsmethod>
  	</jsmethod_list>
</vignette>
