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

Jan M's icon

the title is my question
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 M's icon

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.

j

Luke Hall's icon

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 M's icon

Thanks for all your contributions!

j