Difference between revisions of "LGUI2:LS1:lgui2eventargs"
Jump to navigation
Jump to search
(Created page with "{{ObjectType-Vitals|lgui2eventargs|LavishGUI 2|none|lgui2eventargs|none|no|void *}} A lgui2eventargs object is provided as the Context Top-Level Object when an LGUI2:Ev...") |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
== Members == | == Members == | ||
− | * | + | * [[LGUI2:LS1:lgui2element|lgui2element]] '''Source''': The source of the event being fired. |
− | * [[ObjectType:jsonobject|jsonobject]] Args: Any | + | * [[ObjectType:jsonobject|jsonobject]] '''Args''': Any properties passed with the event |
− | * [[ObjectType:bool|bool]] Handled: TRUE if the event has been acknowledged as handled. | + | * [[ObjectType:jsonvalue|jsonvalue]] '''Args['''key''']''': A value from the Args object, by its key |
+ | * [[ObjectType:bool|bool]] '''Handled''': TRUE if the event has been acknowledged as handled. | ||
== Methods == | == Methods == | ||
Line 64: | Line 65: | ||
echo MOUSE BUTTON RELEASED | echo MOUSE BUTTON RELEASED | ||
} | } | ||
+ | Context:SetHandled[1] | ||
} | } | ||
Line 74: | Line 76: | ||
{ | { | ||
echo testUIController:Test_OnMouseWheel ${Context(type)} ${Context.Source(type)} ${Context.Args} | echo testUIController:Test_OnMouseWheel ${Context(type)} ${Context.Source(type)} ${Context.Args} | ||
+ | Context:SetHandled[1] | ||
} | } | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
method Test_OnButtonMove() | method Test_OnButtonMove() | ||
{ | { | ||
echo testUIController:Test_OnButtonMove ${Context(type)} ${Context.Source(type)} ${Context.Args} | echo testUIController:Test_OnButtonMove ${Context(type)} ${Context.Source(type)} ${Context.Args} | ||
+ | Context:SetHandled[1] | ||
} | } | ||
Line 129: | Line 128: | ||
atom atexit() | atom atexit() | ||
{ | { | ||
− | LGUI2.Element[demo window]: | + | LGUI2.Element[demo window]:Destroy |
} | } | ||
− | + | ||
− | [[Category:LavishGUI 2 | + | {{LGUI2:ObjectType}} |
+ | [[Category:LavishGUI 2 Events]] |
Latest revision as of 13:41, 5 October 2019
lgui2eventargs | |
Defined By | LavishGUI 2 |
Inherits | none |
Reduces To | lgui2eventargs |
Variable Object Type | none |
Uses Sub-Types | no |
C/C++ Type | void * |
A lgui2eventargs object is provided as the Context Top-Level Object when an Event Handler is handling an event.
Members
- lgui2element Source: The source of the event being fired.
- jsonobject Args: Any properties passed with the event
- jsonvalue Args[key]: A value from the Args object, by its key
- bool Handled: TRUE if the event has been acknowledged as handled.
Methods
- SetHandled: Sets the event "Handled" state to TRUE. This is generally recommended within event handlers. Hooks in particular will ignore the Handled state.
Examples
Handling input events to an element
- testui-demo.json
{ "type": "window", "name": "demo window", "title": "My Window", "content": { "type": "button", "name": "myButton", "horizontalAlignment": "stretch", "verticalAlignment": "stretch", "content": "This is my button!", "eventHandlers": { "onMouseButtonMove": [ "method", "TestUIController", "Test_OnMouseButtonMove" ], "onButtonMove": [ "method", "TestUIController", "Test_OnButtonMove" ], "onDpadMove": [ "method", "TestUIController", "Test_OnDpadMove" ], "onAxisMove": [ "method", "TestUIController", "Test_OnAxisMove" ], "onMouseMove": [ "method", "TestUIController", "Test_OnMouseMove" ], "onMouseWheel": [ "method", "TestUIController", "Test_OnMouseWheel" ] } } }
- testui.iss
objectdef testUIController { method Initialize() { ; Set up a LavishScript enum to help convert DPad positions to something easily recognizable LavishScript:RegisterEnum[edpad] Enum[edpad]:SetValue[RELEASED,-1] Enum[edpad]:SetValue[N,0] Enum[edpad]:SetValue[NE,45] Enum[edpad]:SetValue[E,90] Enum[edpad]:SetValue[SE,135] Enum[edpad]:SetValue[S,180] Enum[edpad]:SetValue[SW,225] Enum[edpad]:SetValue[W,270] Enum[edpad]:SetValue[NW,315] } method Test_OnMouseButtonMove() { echo testUIController:Test_OnMouseButtonMove ${Context(type)} ${Context.Source(type)} ${Context.Args} if ${Context.Args[position]} { echo MOUSE BUTTON PRESSED } else { echo MOUSE BUTTON RELEASED } Context:SetHandled[1] } method Test_OnMouseMove() { echo testUIController:Test_OnMouseMove ${Context(type)} ${Context.Source(type)} ${Context.Args} } method Test_OnMouseWheel() { echo testUIController:Test_OnMouseWheel ${Context(type)} ${Context.Source(type)} ${Context.Args} Context:SetHandled[1] } method Test_OnButtonMove() { echo testUIController:Test_OnButtonMove ${Context(type)} ${Context.Source(type)} ${Context.Args} Context:SetHandled[1] } method Test_OnDpadMove() { echo testUIController:Test_OnDpadMove ${Context(type)} ${Context.Source(type)} ${Context.Args} echo DPAD: ${Context.Args[position].Int(edpad)} switch ${Context.Args[position].Int(edpad)} { case RELEASED ; echo DPAD: RELEASED break case N ; echo DPAD: UP break case E ; echo DPAD: RIGHT break case S ; echo DPAD: DOWN break case W ; echo DPAD: LEFT break } } method Test_OnAxisMove() { echo testUIController:Test_OnAxisMove ${Context(type)} ${Context.Source(type)} ${Context.Args} } } variable(global) testUIController TestUIController function main() { LGUI2:LoadFile["testui-demo.json"] while 1 waitframe } ; Clean up our GUI when the controller script exits (could also be in testUIController:Shutdown) atom atexit() { LGUI2.Element[demo window]:Destroy }
LavishGUI 2 Element Types
- Base Element Types: Element - Content Container - Headered Content Container - Item List
- Layout: anchor - border - dockpanel - dragger - expander - hud - map - page - pagecontrol -panel - popup - radialpanel - screen - scrollviewer - stackpanel - tab - tabcontrol - table - treepanel - window - wrappanel
- Display: canvas - imagebox - progressbar - radialgauge - textblock
- Interaction: button - checkbox - combobox - contextmenu - dragin - filepicker - itemview - knob - listbox - mapitemview - objectview - propertyview - scrollbar - sensitivebutton - slider - textbox
LavishGUI 2 LavishScript Object Types
- Core API (see Using LavishGUI 2 from LavishScript)
- lgui2 - lgui2animateargs - lgui2animationtype - lgui2elementref - lgui2eventargs - lgui2eventhandler - lgui2elementtype - lgui2itemviewgeneratorargs - lgui2inputbinding - lgui2layer - lgui2skin - lgui2trigger
- Enums
- elgui2animationframestate - elgui2dpad - elgui2edge - elgui2fontflags - elgui2horizontalalignment - elgui2imageorientation - elgui2progresstext - elgui2scrollbar - elgui2sizetocontent - elgui2verticalignment - elgui2visibility
- Element Components
- lgui2animation - lgui2brush - lgui2fontstyle - lgui2margins - lgui2item - lgui2property - lgui2radialitem - lgui2radialgaugeneedle
- Element Base Types
- lgui2element - lgui2bordered - lgui2contentbase - lgui2headeredcontentbase - lgui2itemlist
- Elements
- Layout: lgui2anchor - lgui2border - lgui2dockpanel - lgui2dragger - lgui2expander - lgui2hud - lgui2map - lgui2page - lgui2pagecontrol - lgui2panel - lgui2popup - lgui2radialpanel - lgui2screen - lgui2scrollviewer - lgui2stackpanel - lgui2tab - lgui2tabcontrol - lgui2table - lgui2treepanel - lgui2window - lgui2wrappanel
- Display: lgui2canvas - lgui2imagebox - lgui2progressbar - lgui2radialgauge - lgui2textblock
- Interaction: lgui2button - lgui2checkbox - lgui2combobox - lgui2contextmenu - lgui2dragin - lgui2filepicker - lgui2itemview - lgui2knob - lgui2listbox - lgui2mapitemview - lgui2objectview - lgui2propertyview - lgui2scrollbar - lgui2sensitivebutton - lgui2slider - lgui2textbox