displayAddEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(add. classification)
(add description, example)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Add an event handler to the given display. Returns id of the handler or -1 when failed. |= Description
| Add an event handler to the given display. Returns id of the handler 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.
 
See [[User_Interface_Event_Handlers|User Interface Event Handlers]] for the full list of handler 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
____________________________________________________________________________________________
____________________________________________________________________________________________


| display '''displayAddEventHandler''' [handler name,function] |= Syntax
| display '''displayAddEventHandler''' [handlerName, function] |= Syntax
 
|p1= display: [[Display]] |= PARAMETER1


|p1= display: [[Display]] |= PARAMETER1
|p2= [handlerName, function]: [[Array]] |= PARAMETER2


|p2= [handler name,function]: [[Array]] |= PARAMETER2
|p3= handlerName: [[String]] |= Parameter 3


|p3= |= PARAMETER3
|p4= function: [[String]] |= Parameter 4


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




|x1= <code>(example)</code>|= EXAMPLE1
|x1= <pre>module_keyDownEHId = displaySetEventHandler ["KeyDown", "_this call module_keyDown"];</pre> |= Example 1
 
|x2= <pre>#include "\ca\editor\Data\Scripts\dikCodes.h"
 
moduleName_keyDown =
{
private["_handled", "_ctrl", "_dikCode", "_shift", "_ctrl", "_alt"];
_ctrl = _this select 0;
_dikCode = _this select 1;
_shift = _this select 2;
_ctrl = _this select 3;
_alt = _this select 4;
 
_handled = false;
 
if (!_shift && !_ctrl && !_alt) then
{
if (_dikCode in ([DIK_F]+(actionKeys "NetworkStats"))) then
{
nul = [_ctrl] execVM "path\script.sqf";
_handled = true;
};
};
 
_handled; 
};
 
moduleName_keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", "_this call moduleName_keyDown"];
 
//(findDisplay 46) displayRemoveEventHandler ["KeyDown", moduleName_keyDownEHId];
 
</pre> |= Example 2


____________________________________________________________________________________________
____________________________________________________________________________________________


| [[disableSerialization]], [[display]], [[displayRemoveAllEventHandlers]], [[displayRemoveEventHandler]] |= SEEALSO  
| [[disableSerialization]], [[display]], [[displayRemoveAllEventHandlers]], [[displayRemoveEventHandler]], [[displaySetEventHandler]], [[User_Interface_Event_Handlers|UI Event Handlers]], [[findDisplay]], [[DIK_KeyCodes|DIK KeyCodes]], [[keyName]] |= SEEALSO  


|  |= MPBEHAVIOUR  
|  |= MPBEHAVIOUR  

Revision as of 03:49, 26 June 2009

Hover & click on the images for description

Description

Description:
Add an event handler to the given display. Returns id of the handler 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. See User Interface Event Handlers for the full list of handler 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 [handlerName, function]
Parameters:
display: Display
[handlerName, function]: Array
handlerName: String
function: String
Return Value:
Number

Examples

Example 1:
module_keyDownEHId = displaySetEventHandler ["KeyDown", "_this call module_keyDown"];
Example 2:
#include "\ca\editor\Data\Scripts\dikCodes.h"

moduleName_keyDown = { private["_handled", "_ctrl", "_dikCode", "_shift", "_ctrl", "_alt"]; _ctrl = _this select 0; _dikCode = _this select 1; _shift = _this select 2; _ctrl = _this select 3; _alt = _this select 4;

_handled = false;

if (!_shift && !_ctrl && !_alt) then { if (_dikCode in ([DIK_F]+(actionKeys "NetworkStats"))) then { nul = [_ctrl] execVM "path\script.sqf"; _handled = true; }; };

_handled; };

moduleName_keyDownEHId = (findDisplay 46) displayAddEventHandler ["KeyDown", "_this call moduleName_keyDown"];

//(findDisplay 46) displayRemoveEventHandler ["KeyDown", moduleName_keyDownEHId];

Additional Information

See also:
disableSerializationdisplaydisplayRemoveAllEventHandlersdisplayRemoveEventHandlerdisplaySetEventHandlerUI 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

Bottom Section