Difference between revisions of "LGUI2:Hooks"
Jump to navigation
Jump to search
(One intermediate revision by the same user not shown) | |||
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 == | ||
Line 41: | Line 41: | ||
} | } | ||
+ | {{LGUI2:Topic}} | ||
[[Category:LavishGUI 2|LavishGUI 2]] | [[Category:LavishGUI 2|LavishGUI 2]] | ||
[[Category:LavishGUI 2 Events]] | [[Category:LavishGUI 2 Events]] |
Latest revision as of 04:32, 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" } }
LavishGUI 2 Topics