Get position of a bpatcher on load

roger.carruthers's icon

Title says it all; how can I get the position of a bpatcher within its parent patcher upon loading?
Banging a 'window getsize' message to a thispatcher within the bpatcher doesn't appear to work, and anyway, this would get the patchers location relative to the screen origin, not the parent patcher's,
cheers
Roger

Luke Hall's icon

You can do this with javascript, it looks like you'd need something like the following in a [js] object in the subpatch you have loaded into the [bpatcher]:

function loadbang() {
    loc = this.patcher.box.rect;
    outlet(0,loc[0],loc[1]);
}
Ben Bracken's icon
Max Patch
Copy patch and select New From Clipboard in Max.

If you want to avoid javascript, you can use pattr and the @bindto attribute: