Forums > Javascript

How do I create an object in a subpatch.

Feb 17 2014 | 5:24 pm

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.

Feb 18 2014 | 1:44 am

[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. —
Feb 18 2014 | 7:26 pm

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

Feb 19 2014 | 9:33 pm

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

Feb 19 2014 | 10:09 pm

You can do something like this:

sub.subpatcher().newdefault(100, 100, "button")

Apr 01 2014 | 6:37 pm


Jun 18 2014 | 1:34 pm

sub.subpatcher().newdefault(100, 100, "button")


Viewing 7 posts - 1 through 7 (of 7 total)

Forums > Javascript