displaySetEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (exsample 2 how to use)
m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(86 intermediate revisions by 12 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. |= Description
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| display '''displaySetEventHandler''' [handler name, function] |= Syntax
|game4= tkoh
|version4= 1.00


|p1= display [[Display]] |= Parameter 1
|game5= arma3
|version5= 0.50


|p2= [handler name, function] [[Array]] |= Parameter 2
|gr1= GUI Control - Event Handlers


| [[Nothing]] |= Return value
|gr2= Event Handlers
____________________________________________________________________________________________
 
|x1= <pre>_control displaySetEventHandler ["KeyDown", ""]</pre> |= Example 1
|x2= <pre>
//init.sqf start
keyspressed = compile preprocessFile "keyspressed.sqf";


_display = findDisplay 46;
|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.
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'''').}}


_display displaySetEventHandler ["KeyDown","_this call keyspressed"];
|s1= display [[displaySetEventHandler]] [handlerName, function]


//init.sqf end
|p1= display: [[Display]]


//keyspressed.sqf start
|p2= handlerName: [[String]]


switch((_this select 1))do
|p3= function: [[String]] - code


{
|r1= [[Nothing]]


//F key
|x1= <sqf>_control displaySetEventHandler ["KeyDown", ""];</sqf>


case 33:  
|x2= {{hl|init.sqf}}:
<sqf>
KeysPressed = compile preprocessFile "keysPressed.sqf";
private _display = findDisplay 46;
_display displaySetEventHandler ["KeyDown", "_this call KeysPressed"];
</sqf>


{
{{hl|keysPressed.sqf}}:
action here
<sqf>
private _handled = false;
switch (_this select 1) do {
// F key
case 33: {
// code here
_handled = true;
};
};
};
};
_handled;
</sqf>


////init.sqf end
|seealso= [[ListOfKeyCodes]] [[displayAddEventHandler]] [[displayRemoveEventHandler]] [[displayRemoveAllEventHandlers]] [[ctrlSetEventHandler]] [[User_Interface_Event_Handlers|UI Event Handlers]] [[DIK_KeyCodes|DIK KeyCodes]] [[keyName]]
 
}}
</pre> |= Example 2
____________________________________________________________________________________________
 
| [[ctrlSetEventHandler]] |= See also


{{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 -->
Here is a list of key codes, which I found out with a German keyboard (SAITEK): <br>
* ESC = 1
* F1 = 59
* F2 = 60
* F3 = 61
* F4 = 62
* F5 = 63
* F6 = 64
* F7 = 65
* F8 = 66
* F9 = 67
* F10 = 68
* F11 = 87
* F12 = 88
* PRINT = 183
* SCROLL = 70
* PAUSE = 197
* ^ = 41
* 1 = 2
* 2 = 3
* 3 = 4
* 4 = 5
* 5 = 6
* 6 = 7
* 7 = 8
* 8 = 9
* 9 = 10
* 0 = 11
* ß = 12
* ´ = 13
* Ü = 26
* Ö = 39
* Ä = 40
* # = 43
* < = 86
* , = 51
* . = 52
* - = 53
* + = NOT DEFINED
* POS1 = 199
* TAB = 15
* ENTER = 28
* DELETE = 211
* BACKSPACE = 14
* INSERT = 210
* END = 207
* PAGEUP = 201
* PAGEDOWN = 209
* CAPS = 58
* A = 30
* B = 48
* C = 46
* D = 32
* E = 18
* F = 33
* G = 34
* H = 35
* I = 23
* J = 36
* K = 37
* L = 38
* M = 50
* N = 49
* O = 24
* P = 25
* Q = 16
* U = 22
* R = 19
* S = 31
* T = 20
* V = 47
* W = 17
* X = 45
* Y = 44
* Z = 21
* SHIFTL = 42
* SHIFTR = 54
* UP = 200
* DOWN = 208
* LEFT = 203
* RIGHT = 205
* NUM_0 = 82
* NUM_1 = 79
* NUM_2 = 80
* NUM_3 = 81
* NUM_4 = 75
* NUM_5 = 76
* NUM_6 = 77
* NUM_7 = 71
* NUM_8 = 72
* NUM_9 = 73
* NUM_+ = 78
* NUM = 69
* NUM_/ = 181
* NUM_* = 55
* NUM_- = 74
* NUM_, = 83
* NUM_ENTER = 156
* STRGL = 42
* STRGR = 157
* WINL = 220
* WINR = 219
* ALT = 56
* SPACE = 57
* ALTGR = 184
* APP = 221
--[[User:T D|T_D]] 13:37, 8 December 2006 (CET)
<!-- 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}}}}]]

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.