Forums > MaxMSP

Selecting objects in a LOCKED patcher

April 19, 2007 | 7:51 am

I posted this to the javascript list but there isn’t much traffic there at
the moment. I’ve worked through the examples and tutorials but now find I
need some more examples.

In short, I need to know the javascript method for point-in-rect.

More specifically, I would like to click while depressing shift or some
other modifier that does not have a meaning in a locked patcher and have a
javascript report the name, type and rect of the object located at the mouse
click. I have kludged this with the output of patchdescribe-example.pat and
a very messy max patch. I am sure there is a simple javascript way of doing
this.

The input would be the coordinates of the mouse click when the modifier key
is depressed. Java would search all of the objects and report info on the
first one it finds whose rectangle includes the point at the mouse click or
a bang if it searches the entire list without finding an object.

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson


April 19, 2007 | 1:36 pm

Have a look at this patch that Jeremy recently posted:

http://www.cycling74.com/forums/index.php?t=msg&rid=3579&S=3a6b246e17cf520fbcd95a72064f0c72&th=25545&goto=100865#msg_100878

Cheers,
Mattijs


April 21, 2007 | 12:53 pm

try this…

hth

/*j

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 253 126 56 196617 p message;
#P objectname amessage[16];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 269 109 37 196617 p text;
#P objectname sometext[16];
#P button 253 109 15 0;
#P objectname abutton[16];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 252 83 56 196617 p message;
#P objectname amessage[17];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 268 66 37 196617 p text;
#P objectname sometext[17];
#P button 252 66 15 0;
#P objectname abutton[17];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 253 213 56 196617 p message;
#P objectname amessage[18];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 269 196 37 196617 p text;
#P objectname sometext[18];
#P button 253 196 15 0;
#P objectname abutton[18];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 252 172 56 196617 p message;
#P objectname amessage[19];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 268 155 37 196617 p text;
#P objectname sometext[19];
#P button 252 155 15 0;
#P objectname abutton[19];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 253 258 56 196617 p message;
#P objectname amessage[20];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 269 242 37 196617 p text;
#P objectname sometext[20];
#P button 253 242 15 0;
#P objectname abutton[20];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 178 126 56 196617 p message;
#P objectname amessage[11];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 194 109 37 196617 p text;
#P objectname sometext[11];
#P button 178 109 15 0;
#P objectname abutton[11];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 178 83 56 196617 p message;
#P objectname amessage[12];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 194 66 37 196617 p text;
#P objectname sometext[12];
#P button 178 66 15 0;
#P objectname abutton[12];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 179 213 56 196617 p message;
#P objectname amessage[13];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 195 196 37 196617 p text;
#P objectname sometext[13];
#P button 179 196 15 0;
#P objectname abutton[13];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 180 172 56 196617 p message;
#P objectname amessage[14];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 196 155 37 196617 p text;
#P objectname sometext[14];
#P button 180 155 15 0;
#P objectname abutton[14];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 181 261 56 196617 p message;
#P objectname amessage[15];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 197 245 37 196617 p text;
#P objectname sometext[15];
#P button 181 245 15 0;
#P objectname abutton[15];
#N vpatcher 10 59 610 459;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 123 69 30 196617 t b s;
#P window linecount 1;
#P newex 143 239 64 196617 fromsymbol;
#P newex 143 216 40 196617 itoa;
#P newex 143 117 47 196617 zl iter 1;
#P newex 143 138 60 196617 split 48 57;
#P window linecount 0;
#P newex 143 93 40 196617 atoi;
#P outlet 143 299 15 0;
#P inlet 123 34 15 0;
#P window linecount 1;
#P newex 143 192 46 196617 zl group;
#P connect 1 0 8 0;
#P connect 8 1 3 0;
#P connect 3 0 5 0;
#P connect 5 0 4 0;
#P fasten 8 0 0 0 128 174;
#P connect 4 0 0 0;
#P connect 0 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 2 0;
#P pop;
#P newobj 538 406 96 196617 p extract_numbers;
#P newex 627 507 48 196617 loadbang;
#P newex 582 183 32 196617 sel 0;
#P newex 523 214 40 196617 t l l l;
#P newex 538 243 54 196617 onebang 1;
#P newex 497 83 52 196617 metro 50;
#P toggle 624 180 15 0;
#P toggle 624 142 15 0;
#P toggle 642 142 15 0;
#P message 632 83 61 196617 interval 50;
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 112 126 56 196617 p message;
#P objectname amessage[6];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 128 109 37 196617 p text;
#P objectname sometext[6];
#P button 112 109 15 0;
#P objectname abutton[6];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 111 83 56 196617 p message;
#P objectname amessage[7];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 127 66 37 196617 p text;
#P objectname sometext[7];
#P button 111 66 15 0;
#P objectname abutton[7];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 112 213 56 196617 p message;
#P objectname amessage[8];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 128 196 37 196617 p text;
#P objectname sometext[8];
#P button 112 196 15 0;
#P objectname abutton[8];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 40 260 56 196617 p message;
#P objectname amessage[9];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 56 243 37 196617 p text;
#P objectname sometext[9];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 111 172 56 196617 p message;
#P objectname amessage[10];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 127 155 37 196617 p text;
#P objectname sometext[10];
#P button 40 243 15 0;
#P objectname abutton[9];
#P button 111 155 15 0;
#P objectname abutton[10];
#P newex 538 471 62 196617 prepend set;
#P window linecount 2;
#P comment 140 441 204 196617 i’m using my [posit] external to obtain
all namedobjects in a patch and this works;
#P window linecount 1;
#P newex 538 383 44 196617 zl nth 2;
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 41 126 56 196617 p message;
#P objectname amessage[5];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 57 109 37 196617 p text;
#P objectname sometext[5];
#P button 41 109 15 0;
#P objectname abutton[5];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 40 83 56 196617 p message;
#P objectname amessage[4];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 56 66 37 196617 p text;
#P objectname sometext[4];
#P button 40 66 15 0;
#P objectname abutton[4];
#P newex 538 265 56 196617 t names b;
#P newex 538 361 100 196617 zl reg;
#P newex 538 338 32 196617 sel 1;
#N vpatcher 718 101 1318 501;
#P window setfont "Sans Serif" 9.;
#P newex 104 66 100 196617 unpack s s 0 0 0 0 s;
#P newex 204 192 27 196617 &&;
#P newex 120 239 27 196617 &&;
#P newex 120 192 27 196617 &&;
#P newex 267 88 58 196617 unpack 0 0;
#P newex 148 158 27 196617 >;
#P newex 232 159 27 196617 >;
#P newex 204 159 27 196617 < ;
#P newex 120 158 27 196617 < ;
#P inlet 267 43 15 0;
#P outlet 120 310 15 0;
#P inlet 104 35 15 0;
#P connect 0 0 11 0;
#P connect 11 2 3 0;
#P connect 3 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 1 0;
#P connect 7 0 3 1;
#P connect 6 0 8 1;
#P connect 10 0 9 1;
#P connect 11 4 6 0;
#P connect 7 0 6 1;
#P connect 11 3 4 0;
#P connect 4 0 10 0;
#P connect 7 1 4 1;
#P connect 5 0 10 1;
#P connect 11 5 5 0;
#P connect 7 1 5 1;
#P connect 2 0 7 0;
#P pop;
#P newobj 538 314 56 196617 p compare;
#P newex 538 288 40 196617 posit;
#P newex 584 288 36 196617 zl reg;
#P newex 523 494 62 196617 prepend set;
#P newex 500 645 209 196617 sprintf script move amessage[%ld] %ld %ld;
#P newex 494 581 208 196617 sprintf script move sometext[%ld] %ld %ld;
#P newex 479 671 199 196617 sprintf script move abutton[%ld] %ld %ld;
#P window setfont "Sans Serif" 24.;
#P number 538 430 96 24 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 9.;
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 37 172 56 196617 p message;
#P objectname amessage[3];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 53 155 37 196617 p text;
#P objectname sometext[3];
#P button 37 155 15 0;
#P objectname abutton[3];
#P newex 624 160 27 196617 &&;
#P newex 613 114 66 196617 modifiers;
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 111 260 56 196617 p message;
#P objectname amessage[2];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 127 243 37 196617 p text;
#P objectname sometext[2];
#N vpatcher 20 74 620 474;
#P outlet 305 190 15 0;
#P outlet 217 191 15 0;
#P inlet 211 92 15 0;
#P pop;
#P newobj 39 213 56 196617 p message;
#P objectname amessage[1];
#N vpatcher 20 74 620 474;
#P outlet 220 183 15 0;
#P inlet 219 105 15 0;
#P pop;
#P newobj 55 196 37 196617 p text;
#P objectname sometext[1];
#P button 39 196 15 0;
#P objectname abutton[1];
#P newex 632 43 48 196617 loadbang;
#P message 567 605 40 196617 0 0 16;
#P newex 501 625 76 196617 vexpr $i1+$i2;
#P message 560 540 40 196617 0 16 0;
#P newex 494 560 76 196617 vexpr $i1+$i2;
#P message 560 83 42 196617 mode 1;
#P newex 523 163 48 196617 pack 0 0;
#P newex 479 517 54 196617 gate;
#P newex 497 114 114 196617 mousestate;
#B color 5;
#N thispatcher;
#Q end;
#P newobj 479 709 61 196617 thispatcher;
#P button 111 243 15 0;
#P objectname abutton[2];
#P window linecount 2;
#P comment 140 412 258 196617 for some reason the patchdescribe
javascript gives me errors after having moved some objects by scripting;
#P connect 20 0 21 0;
#P connect 19 0 21 0;
#P connect 13 0 14 0;
#P connect 12 0 14 0;
#P connect 33 0 35 0;
#P connect 34 0 35 0;
#P connect 43 0 47 0;
#P connect 46 0 47 0;
#P connect 37 0 38 0;
#P connect 36 0 38 0;
#P connect 21 1 20 0;
#P connect 14 1 13 0;
#P connect 35 1 34 0;
#P connect 47 1 46 0;
#P connect 38 1 37 0;
#P connect 52 0 53 0;
#P connect 51 0 53 0;
#P connect 42 0 45 0;
#P connect 44 0 45 0;
#P connect 15 0 16 0;
#P connect 1 0 16 0;
#P connect 54 0 56 0;
#P connect 55 0 56 0;
#P connect 48 0 50 0;
#P connect 49 0 50 0;
#P connect 53 1 52 0;
#P connect 45 1 44 0;
#P connect 16 1 15 0;
#P connect 56 1 55 0;
#P connect 50 1 49 0;
#P connect 76 0 78 0;
#P connect 77 0 78 0;
#P connect 80 0 81 0;
#P connect 79 0 81 0;
#P connect 74 0 75 0;
#P connect 73 0 75 0;
#P connect 71 0 72 0;
#P connect 70 0 72 0;
#P connect 67 0 69 0;
#P connect 68 0 69 0;
#P connect 78 1 77 0;
#P connect 81 1 80 0;
#P connect 75 1 74 0;
#P connect 72 1 71 0;
#P connect 69 1 68 0;
#P connect 92 0 93 0;
#P connect 91 0 93 0;
#P connect 85 0 87 0;
#P connect 86 0 87 0;
#P connect 94 0 96 0;
#P connect 95 0 96 0;
#P connect 88 0 90 0;
#P connect 89 0 90 0;
#P connect 83 0 84 0;
#P connect 82 0 84 0;
#P connect 93 1 92 0;
#P connect 87 1 86 0;
#P connect 96 1 95 0;
#P connect 90 1 89 0;
#P connect 84 1 83 0;
#P fasten 60 0 4 0 629 203 484 203;
#P connect 4 0 23 0;
#P connect 23 0 2 0;
#P connect 24 0 2 0;
#P connect 25 0 2 0;
#P connect 4 0 7 0;
#P connect 7 0 24 0;
#P fasten 60 0 61 0 629 203 618 203 618 74 502 74;
#P connect 61 0 3 0;
#P connect 6 0 3 0;
#P connect 9 0 25 0;
#P connect 4 0 9 0;
#P connect 3 1 5 0;
#P connect 5 0 63 0;
#P fasten 63 0 26 0 528 234 528 234;
#P connect 41 0 26 0;
#P connect 26 0 4 1;
#P connect 63 1 62 0;
#P connect 62 0 32 0;
#P connect 32 0 28 0;
#P connect 28 0 29 0;
#P connect 29 0 30 0;
#P fasten 30 0 31 0 543 355;
#P connect 31 0 39 0;
#P connect 39 0 66 0;
#P fasten 66 0 22 0 543 431 543 431;
#P connect 22 0 41 0;
#P connect 11 0 6 0;
#P connect 65 0 8 0;
#P connect 8 0 7 1;
#P connect 3 2 5 1;
#P connect 65 0 10 0;
#P connect 10 0 9 1;
#P connect 59 0 64 0;
#P connect 64 0 62 1;
#P connect 32 1 27 0;
#P connect 27 0 29 1;
#P fasten 63 2 27 1 558 238 615 238;
#P connect 57 0 17 0;
#P connect 3 0 59 0;
#P connect 59 0 18 0;
#P connect 18 0 60 0;
#P fasten 28 0 31 1 543 308 633 308;
#P connect 11 0 57 0;
#P connect 58 0 18 1;
#P connect 17 3 58 0;
#P window clipboard copycount 97;


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