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...") |
|||
Line 75: | Line 75: | ||
echo testUIController:Test_OnMouseWheel ${Context(type)} ${Context.Source(type)} ${Context.Args} | echo testUIController:Test_OnMouseWheel ${Context(type)} ${Context.Source(type)} ${Context.Args} | ||
} | } | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
method Test_OnButtonMove() | method Test_OnButtonMove() | ||
{ | { |
Revision as of 21:48, 2 July 2018
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
- ... Source: The source of the event being fired. The returned object will always be derived from lgui2element.
- jsonobject Args: Any parameters passed with the event
- 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 } } 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} } method Test_OnButtonMove() { echo testUIController:Test_OnButtonMove ${Context(type)} ${Context.Source(type)} ${Context.Args} } 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]:ClearChildren:Detach }