so basically, i wan't something like this to happen
test var = list
1
2
3
i want the dropdown to have 1, 2, and 3.
is this possible?
bh
April 18, 2022, 7:07pm
3
Yes and no. There's nothing supporting that particular feature, but you can put Javascript code in the options box and it can do anything it wants. It should return a list of the options. And it's subject to the same restriction as the JS Function block.
what code would get this to work
bh
April 18, 2022, 8:45pm
5
Umm I found a couple of threads about this:
function () {
alert("Yay! JavaScript menu!")
return {
"Option 1" : "Option 1",
"Option 2" : "Option 2"
};
}
Replace the alert function with your own code, and replace Option 1 and Option 2 texts with what you want the menu to display.
Example (Yes I know it's rude)
whenever I try to put a "function" in the input slot options, I can't update the custom block, like the apply button doesn't work, and the ok button doesn't close the dialog, and doesn't update the block.
and I apparently can't change the block shape, or the category.
edit: I just found out that the ok button and the apply button do update the block, they just don't update the parameters if they have a menu, or default value.
its the normal set [var] to [val] block with a reporter in it. i just changed the block spec so the first input slot was a normal string input which accepts reporters. that can be done through javascript or developer mode. once you save and load it turns back to the original dropdown menu but keeps the reporter, which you can rename to whatever variable you wanted to put or swap out with any other reporter.
https://forum.snap.berkeley.edu/t/how-do-i-make-a-custom-javascript-dropdown-in-custom-blocks/6158/2
casually links one of my threads
What was so rude about the project
It called you an idiot if you didn't listen to it
system
Closed
May 19, 2022, 12:58am
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.