Changing styles from script

Top  Previous  Next

Most objects have some sort of style object.  To programmatically change the style, you should pass an object with all the parameters you want changed.  For example, to change the "mainStyle" property so that the font size is 22, you would do:

control.myVal("option", "mainStyle", {fontSize : "22px"})

You can set multiple parts in a single call.  For example to also set it to bold:

control.myVal("option", "mainStyle", {fontSize : "22px", fontWeight : "bold"})

The parameters are normal Javascript names for CSS properties and include:

fontFamily
fontSize
fontColor
backgroundColor
textAlign
fontWeight
fontStyle
textDecoration
paddingLeft
paddingRight
paddingTop
paddingBottom
borderStyle
borderWidth
borderColor

You can actually use any of the others, however, the standard properties window for the control may reset some of them, so typically you should either programmatically change style always, or never.

Note that this does not work with conditional styling.