Dropdown menus via list variables

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

userMenuFromList2 script pic

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




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


mqttPicoXavierPi_pubMod script pic

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


So this handle hierarchical menus
But not certain that I've got the structure right but at least it works :slight_smile:


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 :slight_smile:

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 :slight_smile:

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


menuFromLists3 script pic


More playing around :slight_smile:
Notable extra features
Adding an & in front of an item gives you a cumulative menu

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