Category manipulation

UPDATE: i decided to do it myself, i have some progress:
untitled script pic (8)
small feature request:
untitled script pic
note: the block in the script pic only reports motion color, just an example
i can try to program it myself and make a pr if needed
You can try the experimental version here

I feel like there should instead be a way to get a category color, as well as create and set a category color (excluding the primitive categories). That would be better than getting just the color of a block.

hmm, maybe i can try that

Since we're on that topic, what about also creating categories?

create (category) [name] with color [#</span>338444]::control
//category returns category name for use with
set [category v] of block ({custom block::motion}@</span>addInput::ring grey) to (category)::control
<br/>
custom block::#</span>338444 // block is now in the new category "name"

This idea shouldn't be too hard, considering the devs added the ability to programmatically make blocks.

Bear in mind as you read this that I'm the one who thinks you should be able to do programmatically anything you can do from the GUI.

Still, I'm having trouble imagining a real use for this, and I'm nervous about people putting your proposed block in a loop. I suppose we could deal with the latter concern by hard-coding a limit of 20 categories, or something.

It's different with blocks. I can easily imagine a program creating blocks depending on some data structure, e.g., you invent a block
untitled script pic (2)
which, when called with these inputs, creates blocks
untitled script pic (3)
untitled script pic (4)
untitled script pic (5)
untitled script pic (6)

Can you tell a story like that about program-generated categories?

Organizing the generated blocks from your example into a foods category, perhaps?

that's pretty much my plan, but instead of objects it's texts
also, @bh, do you know how to make a dropdown menu automatically populate?

I still remember the great "getters and setters" discussion.

Yeah, that was pretty great.

Nope. I think you have to do it in JS; that's what I had to do for the colors library.

That's an example of needing one category that you know about in advance of your program running. To need programmatic category creation, it'd have to be


but now it seems like an artificial example just to make a point, not like abstract data types, which are a real thing.

Idea to think about: Blocks are a core programming language feature, but categories are entirely a user interface feature. (Text languages don't have categories, but they do have procedures. If you think of categories as analogous to OOP classes, then there's not enough room in the UI to have a category per class, for any sizable program. How many classes are there in Morphic, for example?)

that's what i'm saying, how do i do it in js?

What exactly do you mean by automatically populate? Are you talking about just having a default value, or have a menu in a different input change based on the first input?

like, how the go to block and any other blocks that use that input type have a dropdown that shows a list of sprites

In a input editor, click on the gear to select a menu.

There's no need to. If you're talking about setting it with snap code, then just take a look at the menu after setting it manually.

image
image
image

As you can see, the options are set to §_objectsMenu, so you can just set the menu to that.

untitled script pic (20)
image

i don't think you understand, i'm editing the source code, which is in javascript

Well then maybe you should look for where it sets the menu when you click the option. You could look for the text $_objectsMenu.

Also, I'm sorry but, I actually don't know how to set it in javascript, and jens doesn't like users talking about javascript on the forum, so you'll have to find out how yourself.

that should be §_objectsMenu, as you said previouslt (the difference is the dollar sign($) instead of the section sign(§))
but i'll look for that in the code