Dropdown menus via list variables

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.

Anything/everthing is possible once you mix hard-code with a bit of JS :slight_smile:

The "hard" bit is avoiding having to do hard-coding :slight_smile:

I'd REALLY like to know why/what this is for :slight_smile:

wait, how can I use your
menuFromLists4 script pic
block with values that are numbers? I can't make a javascript variable called "1", and I certainly can't make javascript variables with spaces.

I only did that block for Brian's benefit so it doesn't contain later code that treats numbers as strings as the other blocks do

And the general answer is that a JS menu produces an object and not simple variables and object keys and values can be string representation of numbers

Also, I'm really bad at JS so the above explanation might be wrong but my other blocks handle number menus fine, so I must have done something right :slight_smile:

image

Edit
e.g this example bit of my code sticks "" at start of concatenation so that JS treats everything as strings and not numbers

output["" + prefix + hasEquals[0]] = hasEquals[1];

ok. I've sort of given up on this, so I'll just use an existing input.

Me too. It's hard to talk about this without knowing what problem you're trying to solve.

I found out another way to do it, and it was also for a mock-up for a program I am going to make. idk why I was trying to make it act exactly how my program is going to be like.