displaySetEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Adjusted the copy-pasted text from the UI Event Handler page.)
m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(60 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma |Game name=
|game1= arma1
|version1= 1.00


|1.00|Game version=
|game2= arma2
____________________________________________________________________________________________
|version2= 1.00


| Sets given event handler of given display.
|game3= arma2oa
|version3= 1.50


The return code of the provided function should indicate whether this event was handled correctly. This implies telling the engine whether it's default code should be executed.  
|game4= tkoh
|version4= 1.00


See [[User_Interface_Event_Handlers|User Interface Event Handlers]] for the full list of handler names.
|game5= arma3
|version5= 0.50


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]].
|gr1= GUI Control - Event Handlers
<br>
{{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'''').}} |DESCRIPTION=
____________________________________________________________________________________________


| display '''displaySetEventHandler''' [handlerName, function] |SYNTAX=
|gr2= Event Handlers


|p1= display: [[Display]] |PARAMETER1=
|descr= Sets given event handler of given display.
|p2= [handlerName, function]: [[Array]] |PARAMETER2=
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.<br>
If applicable, see [[DIK KeyCodes]] for a list of key code constants, which are relevant to key related user interface events like {{Link|User Interface Event Handlers#onKeyDown|onKeyDown}} and {{Link|User Interface Event Handlers#onKeyUp|onKeyUp}}.
{{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'''').}}


|p3= handlerName: [[String]] |PARAMETER3=
|s1= display [[displaySetEventHandler]] [handlerName, function]
|p4= function: [[String]]. {Code} |PARAMETER4=


| [[Nothing]] |RETURNVALUE=
|p1= display: [[Display]]
____________________________________________________________________________________________
 
|x1= <pre>_control displaySetEventHandler ["KeyDown", ""] </pre> |EXAMPLE1=
|x2= init.sqf <pre>
keyspressed = compile preprocessFile "keyspressed.sqf";
_display = findDisplay 46;
_display displaySetEventHandler ["KeyDown","_this call keyspressed"];
</pre>


keyspressed.sqf <pre>
|p2= handlerName: [[String]]
private['_handled'];
 
_handled = false;
|p3= function: [[String]] - code
switch (_this select 1) do
 
{
|r1= [[Nothing]]
//F key
 
case 33:  
|x1= <sqf>_control displaySetEventHandler ["KeyDown", ""];</sqf>
{
 
|x2= {{hl|init.sqf}}:
<sqf>
KeysPressed = compile preprocessFile "keysPressed.sqf";
private _display = findDisplay 46;
_display displaySetEventHandler ["KeyDown", "_this call KeysPressed"];
</sqf>
 
{{hl|keysPressed.sqf}}:
<sqf>
private _handled = false;
switch (_this select 1) do {
// F key
case 33: {
// code here
// code here
_handled = true;
_handled = true;
Line 49: Line 56:
};
};
_handled;
_handled;
</pre> |EXAMPLE2=
</sqf>
____________________________________________________________________________________________


| [[ListOfKeyCodes]], [[displayAddEventHandler]], [[displayRemoveEventHandler]], [[displayRemoveAllEventHandlers]], [[ctrlSetEventHandler]], [[User_Interface_Event_Handlers|UI Event Handlers]], [[DIK_KeyCodes|DIK KeyCodes]], [[keyName]] |SEEALSO=
|seealso= [[ListOfKeyCodes]] [[displayAddEventHandler]] [[displayRemoveEventHandler]] [[displayRemoveAllEventHandlers]] [[ctrlSetEventHandler]] [[User_Interface_Event_Handlers|UI Event Handlers]] [[DIK_KeyCodes|DIK KeyCodes]] [[keyName]]
}}


{{Note
|user= WGL.Q
|timestamp= 20091125180200
|text= Always use [[displayAddEventHandler]] instead, as [[displaySetEventHandler]] '''overwrites''' other (peoples') DEH.
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on Nov 25, 2009
<dt class="note">'''[[User:WGL.Q|kju]]'''
<dd class="note">Always use [[displayAddEventHandler]] instead, as DSetEH '''overwrites''' other (peoples') DEH.
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands|DISPLAYSETEVENTHANDLER]]
[[Category:Scripting Commands ArmA|DISPLAYSETEVENTHANDLER]]
[[Category:Command_Group:_Interaction|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19:43, 3 September 2024

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 onKeyDown and onKeyUp.
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.sqf:
KeysPressed = compile preprocessFile "keysPressed.sqf"; private _display = findDisplay 46; _display displaySetEventHandler ["KeyDown", "_this call KeysPressed"];
keysPressed.sqf:
private _handled = false; switch (_this select 1) do { // F key case 33: { // code here _handled = true; }; }; _handled;

Additional Information

See also:
ListOfKeyCodes displayAddEventHandler displayRemoveEventHandler displayRemoveAllEventHandlers ctrlSetEventHandler UI Event Handlers DIK KeyCodes keyName

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
WGL.Q - c
Posted on Nov 25, 2009 - 18:02 (UTC)
Always use displayAddEventHandler instead, as displaySetEventHandler overwrites other (peoples') DEH.