Forums > Javascript

differentiate between textbutton toggle and button with js?

September 12, 2011 | 9:40 pm

Is it possible to get the mode of a textbutton in javascript? Working from the "patchdescribe.js" in the example, we can find all the textbuttons in a patch, but is it possible to parse out the toggles vs. the momentaries? I’ve tried this, however, "b.mode" doesn’t really give me something I can use. It’s a jsobject, and it’s not really clear how to extract the actual value of the mode so I know if it is a toggle or not.:

function bang()

function iterfun(b)
for(i in b){
return true;
iterfun.local=1; // keep private

September 12, 2011 | 11:19 pm

Try using the getattr() method, here’s a quick example:

var modes = ["button","toggle"];

function bang() {

function iterbutton(a) {
    if(a.maxclass == "textbutton") {
September 13, 2011 | 3:40 pm

Ah, great, thank you! Is getattr documented somewhere? I was looking for something like that in the docs and found nothing.

September 13, 2011 | 10:34 pm

I’m not entirely sure it is, maybe somewhere in the PDF documentation that came with Max4, either that or I learned about it somewhere here on the forum. It does have a few caveats, but if you’re working mainly with UI objects you shouldn’t really get stuck.

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

Forums > Javascript