Forums > Javascript

getting presentation rectangle of object in JS

Apr 18 2011 | 6:50 pm


I know using is a method for getting the patching rectangle of an object in JS, but is there a way to do the same for getting the presentation rectangle? I only saw one old post asking this with no solution.


Apr 18 2011 | 9:52 pm

You can use getattr(), here’s an example of how to find the co-ordinates of a named object in a patcher:

function bang() {
Apr 18 2011 | 10:14 pm

Thanks once again Luke!

Apr 18 2011 | 11:24 pm

Luke, this works great except when I am calling the bpatcher or subpatcher the js object is contained in. I am getting a "jsobject 0" message. Am I doing something stupid?


— Pasted Max Patch, click to expand. —

function getattr(varname, attr)
myobj = this.patcher.parentpatcher.getnamed(varname);
outlet (0, myobj.getattr(attr));


Apr 19 2011 | 1:22 am

Calling your function "getattr" and calling the getattr() method inside that function is probably not the best idea to start with. Your patch works on the [toggle] but not on the [patcher] object when tested. I think this might be a UI object vs non-UI object issue. I’ve never really got to the bottom of what works and what doesn’t with getattr() but maybe I’m missing something simple, perhaps to do with the "sendbox" needed if you send this message with an object box outside of javascript?

Apr 19 2011 | 2:47 am

I think you’re right about UI vs non. I thought it had something to do with hierarchy, but once I tried it on non-UI objects other than the subpatcher I got the same message. I’ll try looking into the "sendbox" thing. Thanks again for your time.

Apr 19 2011 | 3:26 am

Just an update: a bpatcher works if it is not the one containing the js obect, but if it does contain the js object, I get the "jsobject 0" message. So I guess it’s not strictly a UI vs non-UI issue.

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

Forums > Javascript