Style Object

A Style object represents a single user-defined style which collects together a group of text attributes in a particular document. Style objects can be retrieved using:

Style.editingStyles

Document.allStyles

Document.styleWithName

Selection.characterStyle

etc...

Style Type Commands

Style.editingStyle [styleTypeName] v2.0.5

Works just like Style.editingStyles, but returns the first single Style object being edited (or @undefined), instead of an array of styles.

Style.editingStyles [styleTypeName] v2.0.5

Returns an array of Style objects that are currently visible in the active document’s Style Sheet view, ie: those styles chosen in the list of styles on the left side of the Style Sheet view.

Optionally a style type may be given, which limits the kind of styles returned. For a list of possible type names, see the styleType property. If no type is specified, all styles are included.

If no styles are chosen, or the Style Sheet view is not active, returns the @undefined value.

Style Object Properties

.name v1.2

Returns the name of the style. Read-only.

.styleType v1.2

Returns one of the following values that describes the kind of style. Read-only.

Returns

For Style Type

'Character'

A character style that can be applied to individual pieces of text.

'Paragraph'

A paragraph style that always applies to entire paragraphs. Attributes can include ruler settings, like alignment.

'Note'

A style that is applied to the text of either footnotes, endnotes, or section notes. In addition to normal paragraph style attributes, these styles also control note properties such as reference numbering.

'List'

Controls the display and behavior of list items/bullets. List styles are special do not directly define normal textual attributes.

.basedOnStyle v1.2

Returns the Style object the style is based on and inherits attributes from. If the style is not based on another, this returns the @undefined value. Read-only.

.nextStyle v2.0

Returns the Style object that is set as the “next” style (ie: the style that is applied when the user presses the Return key). If the style is not a paragraph style, or there is no next style, this returns the @undefined value. Read-only.

.addedAttributes v1.2

Returns an Attributes object that defines the textual properties (like fontSize) this style adds to any attributes that have been inherited from its “based on style”. Attribute properties that are not explicitly set for this style will have the @undefined value in the returned Attributes object. Read-only.

.attributes v1.2

Returns an Attributes object that combines both the attributes this style adds and those inherited from the “based on style”. If a particular attribute property was never added or inherited it will have the @undefined value in the returned Attributes object. Read-only.

.displayAttributes v1.2

Returns an Attributes object that contains all the attributes of this style, including those inherited from the “based on style”, fixed up for display. For example, if the style does not define a font size, the returned attributes object will have the default value for its fontSize property. In other words, properties in the returned Attributes object are never @undefined unless they are explicitly documented to do so under certain circumstances. Read-only.

Style Object Commands

.setName newName v2.0.5

Changes the name of this style to be the given name. The new name must be unique among all styles in the document. Returns @true on success, or @false if a naming conflict prevented the change.

.setBasedOnStyle newParentStyle v2.0.5

Changes which parent style this style is based on. The new parent must be valid for the style, must be part of the same document, and cannot form a cycle in the stylesheet. To clear the based-on style use the @undefined value as the new parent. Returns @true on success, or @false if the new parent is not legal for some reason.

.setNextStyle nextStyle v2.0.5

Changes the next style (ie: the style that is applied when the user presses the Return key) for this style. The new next style must be valid for the style and must be part of the same document. This command only works for paragraph styles. Returns @true on success, or @false if the next style cannot be set.

.apply v1.3

Applies the style to the currently selected text in the active document.


Previous Chapter
Note Object
<<  index  >>
 
Next Chapter
TrackedChange Object