Setting a colour in a constant

Hey everybody

I know… Yet another newbie question… I am working on my first Website and I am trying to figure out how to set some colours in a constant (or variable) and how to call those within Webstyle. For example, I might have an orange colour that is use for different elements and within different Webstyles and I would like to update all of them by changing just one constant. Is there a way to do that? It is pretty easy in Desktop but in Web?




The way you proceed instead is by creating as many webstyles as needed with the colors you want, then apply them to all the elements style property.

Create a single WebStyle with the color you want and then SubClass the rest of your styles from that. They inherit attributes just like any other class.

I do not understand. How does one change the color attribute of a style out of the editor ? The subclass does not offer a color property…

You don’t. Create a WebStyle with a single entry… TextColor. Then subclass that WebStyle to create the others. If you ever need to globally change the TextColor, you change the top level WebStyle and all of the children inherit the change.

Yes of course. Thanks.

For what it’s worth, I think the fact that you can’t use a constant in the WebStyle editor is a bug. You might want to file a bug report about that.

Greg, you are the “Web Framework Architect”. If you feel that something in the web framework is a bug, then why don’t YOU file a bug report?

I do not quite understand. Since the color property is not exposed, where would the constant be placed ? Or do you mean it would be desirable to have a color property corresponding to the box marked Hex: in the WebStyleEditor for colors ? Then it would be a feature request, right ?

It is true that in JavaScript and HTML one can change colors very precisely in code. Would certainly be nice to be able to do that in Xojo without a hack.

Sometimes it helps when a suggestion comes from users :wink: