Dropdown menus via list variables

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

image

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

image

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

ProjectName=userMenuFromList2&editMode

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

image

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.

image

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

image

ProjectName=menuFromLists&editMode

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

image

ProjectName=menuFromLists2&editMode

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

image

menuFromLists3 script pic

ProjectName=menuFromLists3

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

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

image

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

image

image

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

image

image

ProjectName=menuFromLists4

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

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

And why isn't the existing single cascading menu functionality not enough?

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

Do you mean like this?
image
image

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

something like
image
image
image

The variable called "1" would be
untitled script pic (36)
and the variable called "2" would be
untitled script pic (37)

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

image

that returns

image

yeah.

That's unfortunate :slight_smile:

I'm thinking (without trying to code something) that this is going to be a bit awkward (nothing is usually impossible so I won't say that word) :slight_smile:

The basic issue is that, at the moment, my JS code can read the displayed contents of another slot.

So slot 2 can determine what slot1 is displaying. But it would be very hard to try and determine the contents of the the list variable that produced the slot 1 output

This is because that Snap isn't actually running when you choose a menu item so it is very difficult to find that information out before the script has run.

What is your end requirement for this as there may be another way to achieve your goal

what if slot 3 checks both slot 1 and slot 2 to determine the menu?

I am also gonna be using inputs that don't repeat in variables, so I could have each list hardcoded into the block.