ctrlAddEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "v1\.05\.[0-9]{6}" to "v1.06")
m (formatting)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma2
|game1= arma2


|1.00
|version1= 1.00


|gr1= GUI Control - Event Handlers
|game2= arma2oa
|gr2= Event Handlers


| Add an event handler ([[User Interface Event Handlers]]) to the given control. Returns id of the handler or -1 when failed.<br><br>
|version2= 1.51
{{ Feature | important | Control EHs 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.}}
<br>
{{Feature|important|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'''').}}


| control '''ctrlAddEventHandler''' [handler,function]
|game3= tkoh


|p1= control: [[Control]]
|version3= 1.00


|p2= [handler,function]: [[Array]]
|game4= arma3


|p3= handler: [[String]] - handler name
|version4= 0.50


|p4= function: [[String]] or [[Code]] - script
|gr1= GUI Control - Event Handlers


| [[Number]]
|gr2= Event Handlers


|x1= <code>_map [[ctrlAddEventHandler]] ["draw","_this call BIS_fnc_strategicMapOpen_draw"];</code>
|descr= Add an event handler to the given control.
|x2= <code>_map [[ctrlAddEventHandler]] ["draw",{[[hintSilent]] [[str]] _this}];</code>


|seealso= [[displayAddEventHandler]], [[ctrlRemoveEventHandler]], [[ctrlRemoveAllEventHandlers]]
{{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.
 
* 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'''').
}}
}}


<dl class='command_description'>
|s1= control '''ctrlAddEventHandler''' [handler, function]
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on October 30, 2013 - 11:14</dd>
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]<dd class="note">As of Arma 3 v1.06 [[ctrlAddEventHandler]] and [[displayAddEventHandler]] support script [[Code]] in addition to [[String]] [http://forums.bistudio.com/showthread.php?149636-Development-Branch-Changelog&p=2546439&viewfull=1#post2546439]


|p1= control: [[Control]]
|p2= handler: [[String]] - Handler name, see [[User Interface Event Handlers]]
|p3= function: [[String]], since {{GVI|arma3|1.06}} also [[Code]] - Script
|r1= [[Number]] - Handler ID or -1 if failed


<!-- Note Section END -->
|x1= <code>_map [[ctrlAddEventHandler]] ["draw", "_this [[call]] BIS_fnc_strategicMapOpen_draw"];</code>
</dl>


|x2= <code>_map [[ctrlAddEventHandler]] ["draw", {[[hintSilent]] [[str]] [[_this]]}];</code>


{{GameCategory|arma2|Scripting Commands}}
|seealso= [[displayAddEventHandler]], [[ctrlRemoveEventHandler]], [[ctrlRemoveAllEventHandlers]]
{{GameCategory|arma3|Scripting Commands}}
}}
{{GameCategory|tkoh|Scripting Commands}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Revision as of 10:29, 5 April 2021

Hover & click on the images for description

Description

Description:
Add an event handler to the given control.
  • 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.
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 Arma 3 logo black.png1.06 also Code - Script
Return Value:
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}];

Additional Information

See also:
displayAddEventHandlerctrlRemoveEventHandlerctrlRemoveAllEventHandlers

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