## object = DFrame, Bar, Menu and Button

## object: getStyle

Return the Style of the object .

### Example

var dFrameStyle = dFrame1.getStyle()

dFrameStyle.setBackgroundColor('blue')

var dFrame2 = new DFrame(position, title, dFrameStyle2);

Demo

file: setIndent.html

Run the example
See the source code

### Syntaxes

object.getStyle()

### Parameters

no parameter

### Return value

Depends on the object:

DFrame.getStyle returns a DFrameStyle

Bar.getStyle returns a BarStyle

Button.getStyle returns a ButtonStyle

Menu.getStyle returns a MenuStyle

### Usage

This method allows to extract a style from an object in order to use it for a new one.

It is useful in two cases:

§ When a style is customized for one DFrame and reused for another one:

var dFrameStyle = new DFrameStyle()

var dFrame1 = new DFrameStyle(dFrameStyle)

dFrame1.setBackgroundColor('blue')

…

var dFrame2 = new DFrame(position, title, dFrame1.getStyle());

The blue background color set for dFrame1 will apply to dFrame2

§ When you want to customize the default Styles that will be used: The shortcut syntaxes allowing you to use Styles methods on objects (as in the example above: dFrame1.setBackgroundColor('blue') ) do not allow you to modify default Styles of the object. The getStyle method will do it:

var dFrameStyle = new DFrameStyle()

… (Style definitions)

var dFrame = new DFrame(position, title, dFrameStyle)

dFrame.getStyle().getDefaultBarStyle.setBackgroundColor('blue')

Caution 1: The getStyle method returns a Style if the Style exists: As the Style is mandatory for DFrame's the getStyle method applied to DFrames always returns a Syle. But Bars, Buttons and Menus can only return a Style

§ if they have been instantiated with a style. Example: var bar = dFrame.addButton(buttonStyle)

§ elsewhere after they inherited the defaultStyles of their parents (DFrame for Bars, Bar for Buttons and Menus), that is to say after they have been created.

Caution 2: The getStyle method returns an object, i.e. a handle on the Style: If you modify the return value you modify the original Style.