setStyle

Set Style parameters for the component with the given ID if it exists. Style commands are additive. They can be added or modified, but not removed.

Tip: To view syntax examples for particular styles, use the PanelBuilder user interface to add the style on the Style tab, and then view the resulting code in the Source tab.

For openGear Style Hints for the available style options, refer to the openGear documentation.

Syntax

ogscript.setStyle (Component ID, Style);

Parameters

Parameter

Type

Required

Description

Component ID

String

Yes

ID of the Component to style with the given Style parameters.

Style

String

Yes

Style parameters with which to style the given Component.

Returns

N/A

Example 1

This example defines the style of a label, and then makes three style changes.

//labeldefinition

<labelheight="45" id="label1" left="330" name="Change the style of this label" style="txt-align:west;" top="100" width="325"/>

 

//firstchange - set the background to red ogscript.setStyle('label1',"bg#FF0000");

 

//second change - set the text colour to black and text size to big ogscript.setStyle('label1',"fg#000000;size:big");

 

//third change - modify the text alignmentfrom left to right ogscript.setStyle('label1',"txt-align:east");

Example 2

This example creates a pre-defined style, and applies it to a component. Pre-defined styles can add or replace a component’s style settings, but not remove them.

//createa pre-defined style

<styleid="Style1" name="Style1" value="size:Big;bg#6F63FB;bdr:etched;"/>

//Add a predefined Style to a component ogscript.setStyle('label1',"style:Style1")