Combining Styles?

If I have two styles

  1. Warning
  2. Error

Waring is a solid yellow fill
Error is a Red Border.

If an object has both a warning and an error, how do I combine the two styles (in code)?

Must I make a style myself that is both?

[quote=197749:@Brian O’Brien]If I have two styles

  1. Warning
  2. Error

Waring is a solid yellow fill
Error is a Red Border.

If an object has both a warning and an error, how do I combine the two styles (in code)?

Must I make a style myself that is both?[/quote]

In pure Xojo the best way is to create a third style that combines both, like WarningError for instance.

You can probably change style dynamically with JavaScript, but it is more involved and unless critical need, the Xojo WebStyle is way simpler to use.

If you have Web Custom Controls you can apply multiple WebStyleTD styles to a control. You can also edit WebStyles and WebStyleTD’s at runtime; create new WebStyleTD’s at runtime; use any CSS you like; and modify the styling of a control directly.

If this is a one off thing then obviously it’s easier to create a third style then buy a 3rd party product. But if you have projects with complicated, multi-layered styling then WCC makes life a lot easier.

Easiest way to do this is to add or remove the style using javascript.

And yes, that’s not officially supported. But yes, it’s easy and the chance that in later updates your app will crash is really small.

I have a supported method which I forgot to share, that comes as a separate part of the XDS Web Controls (Open Source Control Library) :slight_smile: Comes in handy when many styles are used… (ie 4 separate styles can yield 9 different styles. 5 styles can be combined into 15 different styles. 6 styles can be combined into 21 different styles, etc) [GREAT TIME SAVER AND MUCH LESS CLUTTER]

http://www.xojodevspot.com/demos/XDSWebClasses.xojo_binary_project

I believe this may be what you are looking for :slight_smile: