Can't create a umenu with JS?

Brennon Bortz's icon

Ok, so why does this work:

function bang(){
this.patcher.newdefault(0,0,"umenu");
}

but this doesn't:

function bang(){
this.patcher.newobject("umenu",0,0);
}

but this DOES work, on the other hand:

function bang(){
this.patcher.newobject("toggle",0,0);
}

Does newobject() only understand certain classes of objects??

Emmanuel Jourdan's icon

On 16 janv. 09, at 03:56, Brennon Bortz wrote:

> Does newobject() only understand certain classes of objects??

Use newdefault() instead:

HTH,
ej

Brennon Bortz's icon

Fair enough--thank you! Now, is it possible to add items to the umenu? I've tried all the combinations I can muster!

Emmanuel Jourdan's icon

On 16 janv. 09, at 04:23, Brennon Bortz wrote:

> Fair enough--thank you! Now, is it possible to add items to the
> umenu? I've tried all the combinations I can muster!

You can just send normal messages to your umenu, with something like
that (email coding):

var umenuObj = this.patcher.newdefault("umenu", 100, 100);
umenuObj.message("append", "toto");
umenuObj.message("append", "titi");
umenuObj.message("append", "tutu");
umenuObj.message("append", "(unselectable item)");
umenuObj.message("append", 74);

It would be better to ask those question on the dedicate JavaScript
forum.
HTH,
ej

Brennon Bortz's icon

I'm sorry for the "mispost"--I'll be happy to post to the JS forum in the future. I must say that there have been times when my questions posted there never go answered, which was the impetus behind posting here. If I'm bothering people though, I'll go back to keeping JS in the JS forum.

That said, as this question is already here, I need to ask a follow-up question. This relates nicely to my other topic about the documentation of JS. I understand that I can send append messages to the newly created [umenu] to add items. However, this seems to be sort of a roundabout way of doing things. If this is the only way to accomplish what I'm trying to do, obviously it's what I'll do. But, does this mean that only certain attributes are directly accessible from within JS? Even ones that are common to all boxes (I had similar problems with textcolor, etc.)? Further, are certain classes of objects only understood by newobject()? If newobject() were being deprecated and superseded by newdefault(), it seems to me that proper documentation would acknowledge this. I may be missing something, but I can't find mention of this in the docs. The docs do claim that JS can be used to do script any message that one can send to a [thispatcher] object ("Any message to a patcher that you can send in Max (via the thispatcher object) you can send in Javascript in js.")--but newobject(umenu) doesn't work! If newobject() is still supported (as the docs would lead one to believe: "If you wish to specify all the object parameters (object width, flags, etc.) you can use the newobject() method instead."), but it cannot recognize certain classes of objects (which are quite a few), or if only certain attributes are accessible to newdefault(), it should be noted in the documentation. Just a bit of legwork with these things on the front-end would save a lot of users an enormous amount banging our heads against the wall. Am I wrong?