Forums > Javascript

onclick.local, ondrag.local, onresize.local: what are they for ?

March 26, 2014 | 4:06 am

Hello,

In the jsui help patch, there’s the 2d vector control example.

One can see lines of code using the onresize.local, onclick.local and ondrag.local variables.

First I do not understand when those lines are executed because they are outside any function (see shortened code below).

Second, what are they for ?

Thank you in advance.

Roald Baudoux

function onresize(w,h)
{
...
}
onresize.local = 1; //private

function onclick(x,y)
{

}
onclick.local = 1; //private

function ondrag(x,y)
{

}
ondrag.local = 1; //private


March 26, 2014 | 5:21 am

Salut Roald,

setting the local property of a function to 1 will make it inacessible from outside the js instance, i.e. from Max patches.

In your example, you cannot send the message onclick(66,666) to the js.

Setting values don’t need to be done within a function, I’m sure you do things like: inlets = 1; in your codes.

p


March 26, 2014 | 5:25 am

OK, the answer is in "Max JS Tutorial 4: Designing User Interfaces in JavaScript".


March 26, 2014 | 5:52 am

Salut Patrick,

I discovered your answer after having posted mine !

Sure code can be put outside functions but it’s a bit strange to see it there…


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