# Dropdown menus via list variables

I've finally managed to make a custom reporter that I've been wanting for ages

It let's you generate a dropdown menu from a list variable
You just supply the name of the variable that contains the list in the second input - you can then select any item of the list in the first menu and it will report that value

I just got it working tonight so probably not the final syntax

You can also do the equivalent of writing

red = 255,0,0
green  = 0,255,0
blue = 0,0,255


in a normal custom block dropdown constructor

and

Love it. Thanks for sharing your inventions!

Very nice! I can use this in my Colors and Crayons library...

Its still a work-in-progress - I want it to be able to emulate all the dropdown options plus I've got my own requirement to do something like this - return the value but still indicate what option was used to select it

And it should support making hierarchical menus out of list structures, please. :~)

It will - just playing around with implementation ideas - I'll throw them out on here for feedback

Version 2 - lots of console debugging in it so not fit for production

But not certain that I've got the structure right but at least it works

Lots of help with the JS from Jack Wearden

8 posts were split to a new topic: Custom dropdown menu support for Colors and Crayons library

So I've re-added the ability (with different syntax structure than 1st attempt) to return an alternate value from the visible menu item displayed e.g return the hex of the colour selected

and then added my own == concept when you still want to see both the menu name and the value it's going to return. Note the reporter only reports the value inside the brackets.

Think of this as being equivalent of using a variable to hold the hex value - the variable is called red but returns FF000

I've come up with an all-in-one block

Instead of user choosing which variable to use for a menu - it scans all global variables and assumes any ending in  menu or  * can be used as menu descriptors and offers all of them as a combined menu

Yet another mod

Decided that my x==y concept should show up as x = y and not x (y)
Plus it's easier to parse in the custom reporter to just report y

More playing around
Notable extra features
Adding an & in front of an item gives you a cumulative menu
e.g

You can get a plain text copy of the generated menu (doesn't handle all my options but does the most common ones) that you can then just paste into a standard menu if you won't need to change it dynmaically

A block that lets you specify which menu you like it to return but with the added bonus that you can collapse the variadic input and it will remember the last value specified using a block variable in the reporter

Also, there is a helper block that will produce nested or cumaltive menus from a sequence of lists

is there a way to make a block that takes 3 inputs, the first one is a variable list, the second is an item number from the list, and the third is a menu from that item number of the list.

For example, I make the first input, "list". Then the second input would have a dropdown for every item number in the list. Let's say I put it to 2. Then the third input dropdown would update to the second item of the list as it's dropdown inputs.

It would really help if you can make something like that.

Not at computer at moment but will look into this for you later

To help clarify what your after, can you give an example a variable list your thinking about

Is it that you want all 3 items returning and not just the final one?

Do you mean like this?

That's what the last version does so I think they want something else

something like

The variable called "1" would be

and the variable called "2" would be

I did also re-think a bit, so my first description doesn't match this.

No problem
Does it have to be 3 separate dropdowns?
What I'm thinking is would you be happy to just have this

that returns