ctrlAddEventHandler: Difference between revisions
Jump to navigation
Jump to search
m (formatting) |
Lou Montana (talk | contribs) m (Text replacement - "\] +\[" to "] [") |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
|game1= arma2 | |game1= arma2 | ||
|version1= 1.00 | |version1= 1.00 | ||
|game2= arma2oa | |game2= arma2oa | ||
|version2= 1.50 | |||
|version2= 1. | |||
|game3= tkoh | |game3= tkoh | ||
|version3= 1.00 | |version3= 1.00 | ||
|game4= arma3 | |game4= arma3 | ||
|version4= 0.50 | |version4= 0.50 | ||
Line 25: | Line 21: | ||
{{Feature|important| | {{Feature|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. | * 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 [[User Interface Event Handlers|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''''). | * When using the event names listed [[User Interface Event Handlers|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''''). | ||
}} | }} | ||
|s1= control | |s1= control [[ctrlAddEventHandler]] [handler, function] | ||
|p1= control: [[Control]] | |p1= control: [[Control]] | ||
|p2= handler: [[String]] - | |p2= handler: [[String]] - handler name, see [[User Interface Event Handlers]] | ||
|p3= function: [[String]], since {{GVI|arma3|1.06}} also [[Code]] - script. Several [[Magic Variables]] are available: | |||
* Event Handler parameters are accessible via {{hl|_this}} | |||
* The Event Handler type is available as {{hl|_thisEvent}} | |||
* The Event Handler index is available as {{hl|_thisEventHandler}} | |||
| | |r1= [[Number]] - handler ID or -1 if failed | ||
| | |x1= <sqf>_map ctrlAddEventHandler ["draw", "_this call BIS_fnc_strategicMapOpen_draw"];</sqf> | ||
| | |x2= <sqf>_map ctrlAddEventHandler ["draw", { hintSilent str _this }];</sqf> | ||
| | |x3= <sqf>findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["draw", { hintSilent str _this }]; //Arma 3 map control</sqf> | ||
|seealso= [[displayAddEventHandler]] | |seealso= [[displayAddEventHandler]] [[ctrlRemoveEventHandler]] [[ctrlRemoveAllEventHandlers]] | ||
}} | }} |
Latest revision as of 11:46, 5 May 2024
Description
- Description:
- Add an event handler to the given control.
- Groups:
- GUI Control - Event HandlersEvent Handlers
Syntax
- Syntax:
- control ctrlAddEventHandler [handler, function]
- Parameters:
- control: Control
- handler: String - handler name, see User Interface Event Handlers
- function: String, since 1.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
- Return Value:
- Number - handler ID or -1 if failed
Examples
- Example 1:
- _map ctrlAddEventHandler ["draw", "_this call BIS_fnc_strategicMapOpen_draw"];
- Example 2:
- Example 3:
- findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["draw", { hintSilent str _this }]; //Arma 3 map control
Additional Information
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