Forums > Javascript

creating new subpatchers in a special way

May 07 2007 | 1:38 pm


As promised, I’m now dipping my toes into javascript. Almost starting to get a hang on it. Now, I’d like to use js to create a new patcher with specific window size and flags at creation time, and keep it from opening. I know how to manipulate the window after creation, but I’d like to set all the properties as it is born.

The Max example patch below illustrates what I’m trying to achieve – except I shouldn’t need the thispatcher and the messages when using js.

Any ideas about these tasks are welcome.

max v2;
#N vpatcher 298 84 898 484;
#P window setfont "Sans Serif" 9.;
#P message 58 82 241 196617 window flags nozoom , savewindow 1 , window exec;
#N vpatcher 140 228 268 540;
#P inlet 21 70 15 0;
#P window setfont "Sans Serif" 9.;
#N thispatcher;
#Q window flags grow close nozoom nofloat;
#Q window size 140 228 268 540;
#Q window title;
#Q window exec;
#Q savewindow 1;
#Q end;
#P newobj 21 99 61 196617 thispatcher;
#P connect 1 0 0 0;
#P pop;
#P newobj 58 123 44 196617 patcher;
#P window linecount 3;
#P comment 112 125 233 196617 < - mission: use js to create a patcher like this (correct window size and flags at creation time , sans the thispatcher and inlet) , and prevent it from opening at creation time;
#P connect 2 0 1 0;
#P pop;

May 10 2007 | 10:47 am

Im only just getting to grips with MAX, but Ive started with Javascript first because Im familiar with it as a language.
So Ive tried, but dont seem to be able to do what you’re asking for, but maybe what Ive found will be of help.

So far:

A patcher created by new.Patcher opens automatically.
A patcher created by this.patcher.newdefault opens automatically.
A patcher created by this.patcher.newobject opens automatically.

I havent managed to discover any reference to parameters for these function calls which might create a hidden Patcher.

The only way I [i]can[/i] manage to create a hidden patcher, is by creating a pcontrol object in javascript, and sending it the message ("shroud", "patchTemplate") where patchTemplate is a potentially empty patch stored as a file. However the problem is that the created patcher seems to be created ‘anonymously’ in that it is [i]not[/i] visible to the js object as an object present in the Patcher. Nor is a Patcher object created within the parent. And since it [i]is[/i] invisible, it cannot be opened…

However if your hidden patcher [i]never[/i] has to be opened, then this might be an option. You might need to use send/receive to pass data to it, though, since I cant work out a a way of connecting to any inlets or outlets on the ‘anonymous’ Patcher.

Hope that helps, some.

May 10 2007 | 12:58 pm

Thanks for the input.

Although I’d like to know if and how it is possible to do all the things I asked for, I really need only one of two things: either prevent the window from opening, or set the correct size and flags at creation time.

The best solution would be to be able to delay the opening, but if that’s impossible, do anyone have any suggestions for the other option, i.e. define size and flags?

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

Forums > Javascript