How do you set text color by name?

How to set the color of a label's text or background by name (e.g. "PURPLE" or "SLATEBLUE"). Can it be done?

Type the hex code of color in labels color properties

No way to use a color name in the blocks? I think I just found that color names can only be used in HTML.

This sample project includes a file of color names and codes:

OK. I was hoping for something like:

image

Looks like there is nothing like that. I can use the codes. Thanks.

You could make a procedure using if then else

@boofuss60 You cannot use color names to set any color.
Why are you not using the in-built color blocks ?

image

Also you can use the hex color codes.

You could do it using dictionary blocks

2 Likes

These are all good ideas. And I can do them.

I'm doing something where I'm working a lot with colors, and it's just faster for me to deal with common names then looking up codes. And the color blocks are great (there's even a built-in color picker!)...I just need are larger set of options. I thought I might be missing a way to use the names.

App Inventor is so friendly sometimes I am surprised that we can't do this. Thanks everyone.