Skip to content
Benedict Allen edited this page Nov 15, 2015 · 4 revisions

Style class.

The style class is what allows the customisation of element visuals.

See field names.

Constructor

Style( Instance object )

A Style should be initialised with the object it refers to. This can be changed later with clone().

Methods

clone()

Style copy = Style:clone()

Returns a style identical to the one being operated on. Changed made to one will not affect the other.

setField()

This function is chainable.

Style:setField( string field, value )

Sets the value of a field for the style, invoking its object's setChanged() function.

getField()

value = Style:getField( string field )

Returns the value of a field for the style.

Static functions

addToTemplate()

Style.addToTemplate( Class class, table fields )

Modifies the default values of a class style. fields should be formatted as follows:

{
    ["field"] = value_one;
    ["field.state"] = value_two;
}

Field names

Field names are identifiers for specific attributes of a style. Some examples:

  • colour
  • textColour.pressed
  • horizontal-alignment.pressed

The syntax of a field name is this: identifier[.state]. When state is not given, it defaults to default, so colour is actually colour.default.

Field names are used by elements for getting colours and other values. Let's take a button as an example. The colour of the button will be determined by colour (colour.default), or colour.pressed when the user is holding the button with their mouse. The various field names are documented by each individual element.

Clone this wiki locally