bpatcher and its parent window
Hi folks, I have been trying to figure out for a little bit.
I want to be able to press a button in a bpatcher, and that will maximize the bpatcher to the size of my current patcher window.
For me to be able to do that, I would need to do the following:
From inside the bpatcher, get the patching window size that contains it.
Set the bpatcher's patching_rect and/or presentation rect from inside the bpatcher.
I have tried js and thispatcher, but I can't seem to get access to the bpatcher object or its parent. Maybe my problem has to do with my path construction? The "thispatcher" help file has sendbox example that moves the bpatcher, however, I need to do it from inside of the bpatcher.
Any help would be greatly appreciated!
Thank you!
i dont think you can resize the bpatcher object other than by re-scripting it, and, while you dont want to hear that, i also would not try do it from inside, because that opens a cans of worms from possible user errors to possible bugs in the bpatcher object when it comes to threading and queue stuff.
that already begins when you want to press a GUI object, where the mouse-up is needed as well as the mouse-down.
that already might work when you would like to control size, position, or view mode of the content, due to the normative power of the de facto.
i would do the "getsize" thing and then delete the bpatcher and create a new one. hopefully it does not require 45 connections.
Thank you for the reply!
I am still a little new to this aspect of Max, so I have a few questions :D
What do you mean by re-scripting? And what kind of issues will I be looking at as far as threading and queues? Because that's kind of the point of bpatcher, no? To encapsulate GUI objects inside a subpatcher.
It seems to me it's a matter of getting access to the patcher object of my parent patcher, so I can send messages to it, which would modify my bpatcher, as it has been demonstrated by the bpatcher and thispatcher helper files. So, what I want to do definitely seems possible, I just need access to the "thispatcher" or its equivalent of the parent patcher from inside the bpatcher.
I mean, I guess I can create send/receive pair to send the messages to a receive object in the parent patcher that's basically connected to a "thispatcher" object. But it would be nice to do it without this work around. It seems I should be able to traverse the patch/subpatch hierarchy either via path like ::parent or javascript.
Thank you!
as seen in [thispatcher] help, you can create and delete objects and connections by a script command to thispatcher.
with bpatchers this is very common and it works quite well (probably better than using javascript) to change the size or the content of a bpatcher object.
with "rescripting" i mean first delete an object, then create a new one. :)
generally send/receive will work from inside as well as using outlets and connections would.
you might run into technical issues for example when you are connecting things in loops or when order matters for some reason (i.e. when you control something else, too from the same button which triggers the change to the bpatcher)
but otherwise just send "getsize" from the bpatcher to the thispatcher of the mother patch, like you would do from an abstraction or [patcher].
Ahh, gotcha. Thank you!
So, basically, from your reply, it seems that the only way to do what I want, I would need to do the following:
1. Drop a "thispatcher" object in the parent patcher.
2. Use either send/receive or outlets, and make an explicit connection from the bpatcher to the "thispatcher"
3. Then I can send it getsize, as well as sendbox rect, etc. All that scripting goodness.
Right?
And my question is:
Can I do this without making an explicit connection? Because it seems to me there is a path system for scripting, and pattrstorage etc can use to traverse to a parent patcher. Or a tree-like structure mirroring the object layout of the patcher in Javascript, so it seems to me I should be able to traverse that tree structure of objects and get access to the parent patcher's object and "speak" to it using messages like I would with thispatcher. Of course, it's possible that Max could cut off access that way, like if the tree structure is a single linked list. And that's what I am trying to figure out.
Is it possible to get at the parent patcher's object without making explicit connections.
ps: another possibility might be dropping a js script that makes the top level patcher's patch object global by wrapping it in a Global var. Not sure if it will work that way though.
Thank you again for your reply.
you must evaluate if you are going to use more than one copy of the bpatcher or not, more than one copy of the motherpatcher or not, and if you are going to use different bpatchers with the same system in the same patcher or not, to be able to properly organize all the send/receives.
but this is a generic problem when using sends. :)

now if you start like this, and you find that it does not work for an unknown reason, then you can try to trigger the action to the bpatcher (attribute change or deletion) either with a delay - or wait for the mouse-up of your GUI knob.
Ah ok. Yah. So, it sounds like there isn't a way for bpatcher to get a handle on the parent patcher object.
Thank you!
I know I'm three years late, but I recently learned from another forum topic that in js, you can access the parent patcher like this:
this.patcher.parentpatcher
And the size of a bpatcher from within that bpatcher with this basic js:
inlets = 1
outlets = 1
function getsize() {
if ( this.patcher.box )
outlet( 0, this.patcher.box.rect );
}
So (untested) this should work too:
outlet( 0, this.patcher.parentpatcher.box.rect );