Page 1 of 1
menu insert
Posted: 30 Nov 2012 15:23
by bananas
is it possible to insert an entry into a menu? like, not just attach it to the end, but insert it somewhere in the middle (for example, next to the currently highlighted cursor position)
Re: menu insert
Posted: 30 Nov 2012 16:54
by bananas
also, it would be really nice to have the option to have menus permanently popped out.
Re: menu insert
Posted: 30 Nov 2012 17:32
by analog604
It is possible to change them... I'm working an example for you to checkout..
Re: menu insert
Posted: 30 Nov 2012 18:31
by analog604
provided you've made a menu object named 'myMenu'
setattribute(myMenu,'items',{'new item1','new item2','new item3'});
to get the current list of menu items:
decl menuList=getattribute(myMenu, 'items');
and use the function subarray(menuList,START,COUNT) to copy items onto/off of the menu into a new array.
I don't have a great example of inserting an item yet.. because this code:
setattribute(myMenu,'items',{subarray(menuList,0,1),'new item 2','new item 3',subarray(menuList,1,sizeof(menuList)-1)});
produces unexpected results in my test.
Re: menu insert
Posted: 30 Nov 2012 19:12
by brianc
analog604 wrote:
I don't have a great example of inserting an item yet.. because this code:
setattribute(myMenu,'items',{subarray(menuList,0,1),'new item 2','new item 3',subarray(menuList,1,sizeof(menuList)-1)});
produces unexpected results in my test.
Same here, and I tried a few variations. It doesn't seem to be a problem with the Menu or the setattribute, but you you create the vector. It seems that mixing strings and subarray() to put together a new vector really doesn't work well. Also had problems mixing strings with direct references to individual vector elements.
Re: menu insert
Posted: 30 Nov 2012 20:52
by analog604
Yes the problem is with the vector/array. It's as if we're using a reference to the array object and not a copy. When I tried to make a copy with additional variable assignment (local to script and object),
I get the same thing.
Attached is a test template for the dynamic menu updating, it's not fully functional because of this 'feature/bug' but you can at least use to see the problem and also replace menu items unless referencing index 0 of the menu.
Maybe I'm just coding it wrong... ? if so then..
!
-J
brianc wrote:
Same here, and I tried a few variations. It doesn't seem to be a problem with the Menu or the setattribute, but you you create the vector. It seems that mixing strings and subarray() to put together a new vector really doesn't work well. Also had problems mixing strings with direct references to individual vector elements.
Re: menu insert
Posted: 30 Nov 2012 21:18
by Phil999
if you need a dynamically editable menu, wouldn't it be easier to build one with a container and buttons/text?
Re: menu insert
Posted: 30 Nov 2012 21:40
by analog604
Yes indeed it would be in my experience, Phil!! I try to avoid using menu objects if at all possible due to their limitations and visibility of parameters ... requiring two more taps than would be needed if a button set is used.
But we found a problem with splicing multiple text containing vectors together that I don't remember running into before.
I've had success using subarray and performing much splicing, but using numeric values.
Phil999 wrote:if you need a dynamically editable menu, wouldn't it be easier to build one with a container and buttons/text?
Re: menu insert
Posted: 01 Dec 2012 08:06
by bananas
In my case here, i actually tried it using a switch set to radio mode, and then text objects on top of that,
BUT, my menu has 19 items, and the switch object is hardcoded at a limit of 16 :p
Re: menu insert
Posted: 01 Dec 2012 15:32
by analog604
So if inserting doesn't work currently in-Lemur, you could maybe swap out the menu items with +/- switches...
otherwise what I've always had to do is use a knob/slider and use something like: setattribute(txtStatus,'content',textArray[floor(knobPos.x*maxitems)])
to display what the current synth parameter selection is.
That way you could go up to 256 items.
Checkout the attached example chopped from one of my gear templates..
cheers!
Jay
bananas wrote:In my case here, i actually tried it using a switch set to radio mode, and then text objects on top of that,
BUT, my menu has 19 items, and the switch object is hardcoded at a limit of 16 :p