How do I create an object in a subpatch.

Feb 17, 2014 at 5:24pm

How do I create an object in a subpatch.

So I have a main patcher (mainpatch), and in it there is a sub patcher (subpatch).
I want to create an object (let’s using button for example) inside that subpatch. How do I do that with scripting?
To make an object in the mainpatch I have been using: this.patcher.newdefault(200, 200, "button");

I tried giving the sub patcher a scripting name (subpatchscript) and using:
var sub = this.patcher.getnamed('subpatchscript');
sub.newdefault(200, 200, "button");

but that does not do anything. Any suggestions?

Thank you very much for the help.

#281411
Feb 18, 2014 at 1:44am

[thispatcher] is an object to which you send messages that affect the patcher within which it resides. Look over the [thispatcher] help file for examples of scripting.

This should get you going.

– Pasted Max Patch, click to expand. –
#281432
Feb 18, 2014 at 7:26pm

Thank you and this is along the right path but I was looking to do this in Javascript.
In other words, how do I assign a global variable name to a subpatcher object, and then create an object inside that. Here is what I have so far with the code accompanying

– Pasted Max Patch, click to expand. –

var x = 0;
var sub = this.patcher.getnamed(‘sub’);
function bang(){
this.patcher.newdefault(x, 100, "button");
x += 50;
}
function makeinsub(){
sub.newdefault(100, 100, "button"); //This does not work
}
//sub.subpatcher.newdefault(100,100,’button’); //neither does this

#281523
Feb 19, 2014 at 9:33pm

Doh! Of course. Well.. can’t help you there but I can bump the thread. :)

#281615
Feb 19, 2014 at 10:09pm

You can do something like this:

sub.subpatcher().newdefault(100, 100, “button”)

#281616
Apr 1, 2014 at 6:37pm

THANK YOU!

#285453

You must be logged in to reply to this topic.