displayAddEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Adding note about using this with Addon's.)
(Clarified a couple things)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Add an event handler to the given display. Returns id of the handler or -1 when failed.
| Add an event handler to the given display. Returns id of the event or -1 when failed.


The provided function should return true/false indicating that the event has handled this event fully or not and whether the engine should execute it's default code or not afterwards.  
The provided code should return true or false indicating whether or not the engine should execute the default action associated with the event afterwards.


See [[User_Interface_Event_Handlers|User Interface Event Handlers]] for the full list of handler names.
See [[User_Interface_Event_Handlers|User Interface Event Handlers]] for the full list of event names.


If applicable, see [[DIK_KeyCodes]] for a list of key code constants, which are relevant to key related user interface events like: [[User_Interface_Event_Handlers#onKeyDown|KeyDown]] & [[User_Interface_Event_Handlers#onKeyUp|KeyUp]]. |= Description
If applicable, see [[DIK_KeyCodes]] for a list of key code constants, which are relevant to key related user interface events like: [[User_Interface_Event_Handlers#onKeyDown|KeyDown]] & [[User_Interface_Event_Handlers#onKeyUp|KeyUp]]. |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| display '''displayAddEventHandler''' [handlerName, function] |= Syntax
| display '''displayAddEventHandler''' [eventName, code] |= Syntax


|p1= display: [[Display]] |= PARAMETER1  
|p1= display: [[Display]] |= PARAMETER1  


|p2= [handlerName, function]: [[Array]] |= PARAMETER2  
|p2= [eventName, code]: [[Array]] |= PARAMETER2  


|p3= handlerName: [[String]] |= Parameter 3
|p3= eventName: [[String]] |= Parameter 3


|p4= function: [[String]] or [[Code]] - script |= Parameter 4
|p4= code: [[String]] or [[Code]] - script |= Parameter 4


| [[Number]] |= RETURNVALUE  
| [[Number]] |= RETURNVALUE  

Revision as of 22:00, 22 June 2014

Hover & click on the images for description

Description

Description:
Add an event handler to the given display. Returns id of the event or -1 when failed. The provided code should return true or false indicating whether or not the engine should execute the default action associated with the event afterwards. See User Interface Event Handlers for the full list of event names. If applicable, see DIK_KeyCodes for a list of key code constants, which are relevant to key related user interface events like: KeyDown & KeyUp.
Groups:
Uncategorised

Syntax

Syntax:
display displayAddEventHandler [eventName, code]
Parameters:
display: Display
[eventName, code]: Array
eventName: String
code: String or Code - script
Return Value:
Number

Examples

Example 1:
moduleName_keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", "hint str _this;"];
Example 2:
moduleName_keyDownEHId = findDisplay 46 displayAddEventHandler ["KeyDown", {hint str _this}];

Additional Information

See also:
ListOfKeyCodesdisableSerializationdisplayRemoveAllEventHandlersdisplayRemoveEventHandlerdisplaySetEventHandlerctrlAddEventHandlerUI Event HandlersfindDisplayDIK KeyCodeskeyName

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on October 30, 2013 - 11:14
Killzone_Kid
As of Arma 3 v1.05.111658 ctrlAddEventHandler and displayAddEventHandler support script Code in addition to String [1]
Posted on March 10, 2014 - 14:52
Axyl
From within an Addon, you must assign the events from a spawned script. eg[] spawn { (findDisplay 46) displayAddEventHandler["KeyDown","_this call my_KeyDownFunctionhandler"]; };

Bottom Section