Description
Add an event handler to the given control.
Important
- Control event handlers are processed in reversed order, i.e. last added: first, first added: last. So if you have an override it should be set up in the 1st added EH.
- When using the event names listed here with the ctrlAddEventHandler, ctrlSetEventHandler, displayAddEventHandler or displaySetEventHandler commands, the prefix "on" in the event name must be removed (e.g. 'ButtonDown' instead of 'onButtonDown').
Syntax
control ctrlAddEventHandler [handler, function]
Parameters:
control: Controlhandler: String - handler name, see User Interface Event Handlersfunction: String, since Arma 3 v1.06 also Code - script. Several Magic Variables are available:- Event Handler parameters are accessible via
_this - The Event Handler type is available as
_thisEvent - The Event Handler index is available as
_thisEventHandler
- Event Handler parameters are accessible via
Returns: Number - handler ID or -1 if failed
Examples
Example 1
_map ctrlAddEventHandler ["Draw", "_this call BIS_fnc_strategicMapOpen_draw"];
Example 2
_map ctrlAddEventHandler ["Draw", { hintSilent str _this }];
Example 3
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { hintSilent str _this }]; //Arma 3 map control
See also
displayAddEventHandler · ctrlRemoveEventHandler · ctrlRemoveAllEventHandlers