displaySetEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|seealso= *\[\[([^ ]+)\]\], \[\[([^ ]+)\]\]" to "|seealso= $1 $2")
m (Some wiki formatting)
 
(18 intermediate revisions by 2 users not shown)
Line 22: Line 22:
|descr= 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]] 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: [[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 {{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'''').}}
{{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'''').}}


Line 36: Line 36:
|r1= [[Nothing]]
|r1= [[Nothing]]


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


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


<dl class="command_description">
{{Note
 
|user= WGL.Q
<dt><dt>
|timestamp= 20091125180200
<dd class="notedate">Posted on Nov 25, 2009</dd>
|text= Always use [[displayAddEventHandler]] instead, as [[displaySetEventHandler]] '''overwrites''' other (peoples') DEH.
<dt class="note">[[User:WGL.Q|kju]]</dt>
}}
<dd class="note">Always use [[displayAddEventHandler]] instead, as DSetEH '''overwrites''' other (peoples') DEH.</dd>
 
</dl>

Latest revision as of 00:59, 14 May 2023

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.