Difference between revisions of "LGUI2:Hooks"

From Lavish Software Wiki
Jump to: navigation, search
Line 1: Line 1:
LavishGUI 2 Hooks provide a way to attach an [[LGUI2:Event Handler|Event Handler]] to another related Element.
+
[[LavishGUI 2]] Hooks provide a way to attach an [[LGUI2:Event Handler|Event Handler]] to another related Element.
  
 
== Defining a Hook ==
 
== Defining a Hook ==

Revision as of 04:12, 15 July 2018

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".

Hook properties
elementType (optional) The element type of an element to attach to
elementName (optional) The name of an element to attach to
flags (optional) Relationship flags for locating the element to attach to. "ancestor" is used by default for hooks.
event The name the event to attach to, in the target element
eventHandler An Event Handler definition

If no optional properties are provided, the parent element (the first ancestor, as per the default flag) 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"
  }
}