Forums > Javascript

Getting umenu selection from JS


April 11, 2013 | 4:09 pm

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?)


Nat
April 11, 2013 | 4:46 pm

Bang into it ?

– Pasted Max Patch, click to expand. –

Nat
April 11, 2013 | 4:47 pm

oops nevermind didn’t notice you needed that in JS


Nat
April 11, 2013 | 5:08 pm

You can get attributes using getattr:

autowatch = 1;

function bang()
{
	var menu = this.patcher.getnamed('menu');
	post(menu.getattr('color'));post();
}

Nat
April 11, 2013 | 5:11 pm

Seems like you can get the items this way :

autowatch = 1;

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

Hi Nat,

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

The getattr stuff will come in handy!

Thanks

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