displaySetEventHandler: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>") |
||
(16 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 [[ | See [[User Interface Event Handlers]] for the full list of handler names.<br> | ||
If applicable, see [[ | 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= < | |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> | |||
_handled = | {{hl|keysPressed.sqf}}: | ||
<sqf> | |||
private _handled = false; | |||
switch (_this select 1) do { | |||
// F key | |||
case 33: { | |||
// code here | |||
_handled = true; | |||
}; | }; | ||
}; | }; | ||
_handled; | _handled; | ||
</ | </sqf> | ||
|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]] | ||
}} | }} | ||
{{Note | |||
|user= WGL.Q | |||
|timestamp= 20091125180200 | |||
|text= Always use [[displayAddEventHandler]] instead, as [[displaySetEventHandler]] '''overwrites''' other (peoples') DEH. | |||
}} | |||
Latest revision as of 19:43, 3 September 2024
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. - 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.sqf:KeysPressed = compile preprocessFile "keysPressed.sqf"; private _display = findDisplay 46; _display displaySetEventHandler ["KeyDown", "_this call KeysPressed"];
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
- Posted on Nov 25, 2009 - 18:02 (UTC)
- Always use displayAddEventHandler instead, as displaySetEventHandler overwrites other (peoples') DEH.
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: GUI Control - Event Handlers
- Command Group: Event Handlers