differentiate between textbutton toggle and button with js?

Sep 12, 2011 at 9:40pm

differentiate between textbutton toggle and button with js?

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

Sep 12, 2011 at 11:19pm

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

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

function bang() {

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

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

Sep 13, 2011 at 10:34pm

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.


You must be logged in to reply to this topic.