menu insert

Discuss problems and solutions.
Post Reply
bananas
Newbie
Posts: 33
Joined: 29 Nov 2012 13:50

menu insert

Post 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)
bananas
Newbie
Posts: 33
Joined: 29 Nov 2012 13:50

Re: menu insert

Post by bananas »

also, it would be really nice to have the option to have menus permanently popped out.
analog604
Regular
Posts: 262
Joined: 29 Dec 2011 15:40
Location: north east, usa

Re: menu insert

Post by analog604 »

It is possible to change them... I'm working an example for you to checkout..
Dashboard gear control templates: User 112 Idx :: LModIt Lite :: SVG image converter for Lemur Canvas
analog604
Regular
Posts: 262
Joined: 29 Dec 2011 15:40
Location: north east, usa

Re: menu insert

Post 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.
Dashboard gear control templates: User 112 Idx :: LModIt Lite :: SVG image converter for Lemur Canvas
brianc
Regular
Posts: 87
Joined: 10 Jan 2012 02:16

Re: menu insert

Post 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.
analog604
Regular
Posts: 262
Joined: 29 Dec 2011 15:40
Location: north east, usa

Re: menu insert

Post 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.. :oops: !

-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.
Attachments
example-inserting-removingMenuItems.jzml.zip
(3.15 KiB) Downloaded 114 times
Dashboard gear control templates: User 112 Idx :: LModIt Lite :: SVG image converter for Lemur Canvas
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: menu insert

Post by Phil999 »

if you need a dynamically editable menu, wouldn't it be easier to build one with a container and buttons/text?
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
analog604
Regular
Posts: 262
Joined: 29 Dec 2011 15:40
Location: north east, usa

Re: menu insert

Post 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?
Dashboard gear control templates: User 112 Idx :: LModIt Lite :: SVG image converter for Lemur Canvas
bananas
Newbie
Posts: 33
Joined: 29 Nov 2012 13:50

Re: menu insert

Post 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
analog604
Regular
Posts: 262
Joined: 29 Dec 2011 15:40
Location: north east, usa

Re: menu insert

Post 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
Attachments
example-knobSliderUpdateText.jzml.zip
(3.15 KiB) Downloaded 119 times
Dashboard gear control templates: User 112 Idx :: LModIt Lite :: SVG image converter for Lemur Canvas
Post Reply