Forums > Javascript

is it possible to read the varname of an object that sends a message to a js object


Jan
June 16, 2009 | 8:01 pm

the title is my question Smile
i started to post this question in the general forum – but i think it belongs to this one.

i attached a patch to illustrate what i mean. in the original scripts i have a huge amount of ubuttons, that dynamically connect to other object. is it possible for a js (or any other object)which object is sending a message?

thanks for any reply!

j



Jan
June 16, 2009 | 10:59 pm

meanwhile i found a solution for my patch: if i use the jsui instead of the ubuttons.
but nevertheless i think it is an interesting question as this seems to be a very basic information max needs to generate in order to make a patch run.
but is this information via api accessible?

so still happy for suggestions. Smile

j


June 17, 2009 | 11:49 am

Thats clever, I would never have thought of using the "ignoreclick" property! Here’s a modification that checks the varname attribute using a regular expression. This means that including another [button] in your patch that is click enabled (with or without a scripting name) will not break the result.

lh

var result;
var pattern = /^b[d+]$/;

function bang() {
    post ("go!n");
}

function whois() {
    result = "no";
    this.patcher.apply (find_bang);
    outlet (0, result);
}

function find_bang(a) {
    if (a.maxclass == "button" && !a.ignoreclick && pattern.test(a.varname)) {
        result = a.varname ;
    }
    return true;
}


Jan
June 17, 2009 | 10:59 pm

Thanks for all your contributions!

j


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