Why I should RTFM

A few days ago, I wrote about how to access the named colors in OpenLaszlo 4.2.0. (Where Have All the Colors Gone?) I even wrote a little example showcasing the colors in the lz.colors array. Then Tucker helpfully directed me to a very complete example in the documentation that showed not only the location of the colors, but also a better way of setting colors.

The W3C provides a list of standard CSS colors, and OpenLaszlo now allows you to use those color names as strings when setting colors.

So in addition to being able to say:

myView.setAttribute("bgcolor", lz.colors.cornflowerblue);

… and of course:

myView.setAttribute("bgcolor", 0x6495ed);

… what’s new is that you can also say:

myView.setAttribute("bgcolor", "cornflowerblue");

Notice that the color name is a string, not a variable. Finally, you can also use the pound (#) notation when setting colors in script:

myView.setAttribute("bgcolor", "#6495ed");

Note that when using pound notation, the color value must be a string.

Leave a Reply

Your email address will not be published. Required fields are marked *