Getting umenu selection from JS

Apr 11, 2013 at 4:09pm

Getting umenu selection from JS

Is it possible to get the selected item (number, not text) from umenu, with some kind of getvalueof() routine?

Also out of interest, is there a way of querying UI objects attributes (those viewed in the inspector?)

#67655
Apr 11, 2013 at 4:46pm

Bang into it ?

– Pasted Max Patch, click to expand. –
#243416
Apr 11, 2013 at 4:47pm

oops nevermind didn’t notice you needed that in JS

#243417
Apr 11, 2013 at 5:08pm

You can get attributes using getattr:

autowatch = 1;

function bang()
{
	var menu = this.patcher.getnamed('menu');
	post(menu.getattr('color'));post();
}
#243418
Apr 11, 2013 at 5:11pm

Seems like you can get the items this way :

autowatch = 1;

function bang()
{
	var menu = this.patcher.getnamed('menu');
	post(menu.getattr('items'));
	post();
}
#243419
Apr 11, 2013 at 5:17pm

Hi Nat,

Turns out I was just being dense, getvalueof() works fine.

The getattr stuff will come in handy!

Thanks

#243420

You must be logged in to reply to this topic.