script object in parent patcher…

Mar 21, 2011 at 10:01pm

script object in parent patcher…

I’m not sure this is possible (well, maybe with js) but here it goes anyway:

I have an abstraction that is used for debugging purposes only. whenever it is created, I would like to have a message box scripted and connected to the rightmost outlet of the abstraction. I don’t think thispatcher will be of much help since that only works on the same level the object is in. I need to script the new object in the PARENT.

Any ideas? Thanks

#55727
Mar 22, 2011 at 12:52am

Is there no way you could load this abstraction into a [bpatcher] so you can leave the message box inside the abstraction and have it clickable from the parent patcher without having to worry about extra scripting?

#200374
Mar 22, 2011 at 4:50am

it’s not impossible, but since it’s for debugging only it’s less of a hassle if it’s an abstraction. It’s really not a big deal to add a message box manually, just wondering if there was a way to automate it… always trying to improve things ;)

#200375
Mar 22, 2011 at 6:12am

Try something like the code below. You might have to change the spacing values but these work fine on my current set up. It assumes your object has 3 inlets. I’m not quite sure how you’d get it to fire when you instantiated the abstraction though.

function bang() {
    p = this.patcher.parentpatcher;
    if (p) {
        b = this.patcher.box;
        loc = b.rect;
        a = p.newdefault(loc[2]-19,loc[1]-20,"message");
        a.set("this is the text");
        p.connect(a,0,b,2);
    } else {
        post("uhoh!n");
    }
}
#200376
Mar 22, 2011 at 6:14am

have been playing with the js object a bit and seems to be working fine. haven’t done any extensive testing yet (it’s rather late).

– Pasted Max Patch, click to expand. –

/*************save js as parentTest.js***********************/

function bang() {

var parent = this.patcher.parentpatcher;

var objCoords= this.patcher.box.rect;

var a = parent.newobject(“message”, objCoords[2] – 19, objCoords[3] + 5, 70, 16);

parent.connect(this.patcher.box, 2, a, 0);
}

#200377
Mar 22, 2011 at 6:15am

seems like you just beat me to it ;)

#200378
Mar 22, 2011 at 6:18am

to get it to fire I use a patcherargs -> [sel done]. seems to work for now. again, have to do serious testing tomorrow. for now I’m happy and will get some sleep!!!

Thanks

#200379
Mar 22, 2011 at 11:21am

Great idea! I’m sure there’s a way to force the object width if you’re adding text to the message box too. It can be done with @fixwidth 1 using [thispatcher] so I image you can achieve the same thing in javascript too somehow.

#200380

You must be logged in to reply to this topic.