Element-Attributes
Pedro Gimeno edited this page 5 years ago

Unless otherwise stated, this refers to this element.

Common values

The following common values may be get and set.

element.label = string
  • A label to display for the element. Used for any text directly associated with an element.
element.pos = Gspot:pos()
  • A positioning table, which inherits from Gspot.pos_mt
    • pos.x is an element's horizontal position, originating in the top-left corner, and relative to element.parent.pos.x if set.
    • pos.y is an element's vertical position, originating in the top-left corner, and relative to element.parent.pos.y if set.
    • pos.w is an element's width.
    • pos.h is an element's height.
    • pos.r is an element's radius. Not fully implemented.
element.style = table
  • A style table which inherits from element.parent.style or Gspot.style. This is initialized without values, and is used to set independent styles.
    • style.unit is a standard unit, used to maintain consistency. Default 16px.
    • style.font is used to render text.
    • style.fg is the foreground colour, used to render text.
    • style.bg is the background colour, used to render group backgrounds.
    • style.labelfg is the foreground colour for labels, which may differ from the element's normal foreground colour. It can be unset, in which case it uses style.fg.
    • style.default is the default button colour.
    • style.hilite is the button hilight colour, used when the mouse is over the element.
    • style.focus is used to render selected options.
element.tip = 'string'
  • Displays string in a box when the mouse is over the element.
element.next = element
  • An element which will receive focus if tab is pressed while this element has focus.

Reserved values

The following common values may be get but not set.

element.elementtype
  • The element type.
element.Gspot
  • A reference to the instance which contains this element.
element.parent
  • A reference to this element's parent element, or nil. This element will be positioned relative to parent's position.
  • use element:addchild(this) and this.parent:remchild(this) to allow relative positioning, where :
    • element is any element
    • this is the element to add or remove from parent's children.
element.children
  • A table containing references to this element's children. See above for usage.
element.display
  • true if the element is to be shown, false if hidden.
  • use element:show() and element:hide() to show and hide an element along with its children.
element.dt
  • Time in seconds since element.update() was called, if element.update is set.