LGUI2:Hooks

From Lavish Software Wiki
Revision as of 19:56, 4 June 2018 by Lax (talk | contribs) (Created page with "LavishGUI 2 Hooks provide a way to attach an LGUI2:Event Handler to another related Element. == Defining a Hook == Each Hook must be defined with a JSON object enclosed ...")
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to navigation Jump to search

LavishGUI 2 Hooks provide a way to attach an Event Handler to another related Element.

Defining a Hook

Each Hook must be defined with a JSON object enclosed by {}, usually as part of a "hooks" property when defining an Element.

Each item in the object is expected to be a string, except "eventHandler".

  • "elementType": Optionally provides the element type of an element to locate
  • "elementName": Optionally provides the name of an element to locate
  • "flags": Optionally provides relationship flags for searching. "ancestor" is used by default for hooks.
  • "event": The name of the event to attach to, in the target element
  • "eventHandler": An Event Handler definition

If no optional properties are provided, the parent element will be the target for the hook.

Examples

From the default skin's checkbox definition

This hook applies the "onUnchecked" Style to the current element, when the nearest checkbox ancestor's (the checkbox containing this element) "onUnchecked" event fires.

"hooks": {
  "onUnchecked": {
    "elementType": "checkbox",
    "event": "onUnchecked",
    "eventHandler": {
    "type": "style",
    "styleName": "onUnchecked"
  }
}