displaySetEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <dl class="command_description"> <dt><dt>" to " <dl class="command_description"> <dt><dt>")
m (Some wiki formatting)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma1
|game1= arma1
|version1= 1.00


|1.00
|game2= arma2
|version2= 1.00
 
|game3= arma2oa
|version3= 1.50
 
|game4= tkoh
|version4= 1.00
 
|game5= arma3
|version5= 0.50


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


| Sets given event handler of given display.
|descr= Sets given event handler of given display.
 
The return code of the provided function should indicate whether this event was handled correctly. This implies telling the engine whether it is default code should be executed.  
The return code of the provided function should indicate whether this event was handled correctly. This implies telling the engine whether it is default code should be executed.  
 
See [[User_Interface_Event_Handlers|User Interface Event Handlers]] for the full list of handler names.<br>
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]] &amp; [[User_Interface_Event_Handlers#onKeyUp|KeyUp]].
 
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]].
<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'''').}}
{{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'''').}}


| display '''displaySetEventHandler''' [handlerName, function]
|s1= display [[displaySetEventHandler]] [handlerName, function]


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


|p3= handlerName: [[String]]
|p2= handlerName: [[String]]
|p4= function: [[String]]. {Code}
 
|p3= function: [[String]] - code


|r1=[[Nothing]]
|r1= [[Nothing]]


|x1= <pre>_control displaySetEventHandler ["KeyDown", ""] </pre>
|x1= <code>_control [[displaySetEventHandler]] ["KeyDown", ""];</code>
|x2= init.sqf <pre>
|x2= init.sqf<code>KeysPressed = [[compile]] [[preprocessFile]] "keysPressed.sqf";
keyspressed = compile preprocessFile "keyspressed.sqf";
[[private]] _display = [[findDisplay]] 46;
_display = findDisplay 46;
_display [[displaySetEventHandler]] ["KeyDown", "_this call keyspressed"];
_display displaySetEventHandler ["KeyDown","_this call keyspressed"];
</code>
</pre>


keyspressed.sqf <pre>
keyspressed.sqf<code>[[private]] _handled = [[false]];
private['_handled'];
[[switch]] (_this [[select]] 1) [[do]]
_handled = false;
switch (_this select 1) do
{
{
//F key
{{cc|F key}}
case 33:  
[[case]] 33:
{
{
// code here
{{cc|code here}}
_handled = true;
_handled = [[true]];
};
};
};
};
_handled;
_handled;
</pre>
</code>


|seealso= [[ListOfKeyCodes]], [[displayAddEventHandler]], [[displayRemoveEventHandler]], [[displayRemoveAllEventHandlers]], [[ctrlSetEventHandler]], [[User_Interface_Event_Handlers|UI Event Handlers]], [[DIK_KeyCodes|DIK KeyCodes]], [[keyName]]
|seealso= [[ListOfKeyCodes]], [[displayAddEventHandler]], [[displayRemoveEventHandler]], [[displayRemoveAllEventHandlers]], [[ctrlSetEventHandler]], [[User_Interface_Event_Handlers|UI Event Handlers]], [[DIK_KeyCodes|DIK KeyCodes]], [[keyName]]
Line 58: Line 63:
<dd class="notedate">Posted on Nov 25, 2009</dd>
<dd class="notedate">Posted on Nov 25, 2009</dd>
<dt class="note">[[User:WGL.Q|kju]]</dt>
<dt class="note">[[User:WGL.Q|kju]]</dt>
<dd class="note">Always use [[displayAddEventHandler]] instead, as DSetEH '''overwrites''' other (peoples') DEH.
<dd class="note">Always use [[displayAddEventHandler]] instead, as DSetEH '''overwrites''' other (peoples') DEH.</dd>


</dl>
</dl>
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Revision as of 17:37, 12 June 2021

Hover & click on the images for description

Description

Description:
Sets given event handler of given display. The return code of the provided function should indicate whether this event was handled correctly. This implies telling the engine whether it is default code should be executed. 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.
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').
Groups:
GUI Control - Event HandlersEvent Handlers

Syntax

Syntax:
display displaySetEventHandler [handlerName, function]
Parameters:
display: Display
handlerName: String
function: String - code
Return Value:
Nothing

Examples

Example 1:
_control displaySetEventHandler ["KeyDown", ""];
Example 2:
init.sqfKeysPressed = compile preprocessFile "keysPressed.sqf"; private _display = findDisplay 46; _display displaySetEventHandler ["KeyDown", "_this call keyspressed"]; keyspressed.sqfprivate _handled = false; switch (_this select 1) do { // F key case 33: { // code here _handled = true; }; }; _handled;

Additional Information

See also:
ListOfKeyCodesdisplayAddEventHandlerdisplayRemoveEventHandlerdisplayRemoveAllEventHandlersctrlSetEventHandlerUI Event HandlersDIK 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
Posted on Nov 25, 2009
kju
Always use displayAddEventHandler instead, as DSetEH overwrites other (peoples') DEH.