js in poly~

Apr 9, 2005 at 7:10pm

js in poly~

Is there a way to access the enclosing poly~ object from within a
poly-enclosed subpatcher? In a javascript in an enclosed poly patcher,
the “this.patcher” property refers, as expected, to the patcher that
poly~ is wrapping. But neither the “box” property nor the
“parentpatcher” property seem to return a usable object.

Using this js in a poly~-wrapped patcher:

var poly1 = this.patcher.box;
var poly2 = this.patcher.parentpatcher;
function loadbang() {
post( poly1 ); // displays “jsobject 0″ in max window
post( poly2 ); // displays “jsobject 0″ in max window

// following results in “TypeError: poly1 has no properties”
post( poly1.maxclass );

// following results in “TypeError: poly2 has no properties”
// comment out the previous error to see this evaluate
post( poly2.maxclass );
}

The documentation references the “subpatcher” method to access
subpatchers inside a poly~ object once you have a reference to the poly~
object in your script, but I can’t figure out how to access a reference
to the poly~ object from inside it…

Any help is greatly appreciated,
Charlie

#23891
Apr 9, 2005 at 7:48pm

>Is there a way to access the enclosing poly~ object from within a poly-enclosed subpatcher? In a javascript in an enclosed poly patcher, the “this.patcher” property refers, as expected, to the patcher that poly~ is wrapping. But neither the “box” property nor the “parentpatcher” property seem to return a usable object.

This is not accessible from any function in js, but it is easily accomplished by sending a message to your js instance from the thispoly~ object.

-Joshua

#68193
Oct 6, 2009 at 1:07am

Quote: jkc wrote on Sat, 09 April 2005 15:48
—————————————————-

> This is not accessible from any function in js, but it is easily accomplished by sending a message to your js instance from the thispoly~ object.
>
> -Joshua
>
—————————————————-

Joshua, if you get this, or anyone else who knows, could you elaborate on what you mean? I’ve been trying everything I can think of within [js] to get the enclosing [poly~] with the goal of finding [pattr] paths. I think I’ve found a work around, but I think what Joshua alludes to here might be more elegant. Could anyone clarify this?

#68194

You must be logged in to reply to this topic.