displayAddEventHandler: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Text replacement - "<code>([^<]*)\{\{=\}\}([^<]*)<\/code>" to "<code>$1=$2</code>") |
||
Line 81: | Line 81: | ||
{ | { | ||
params ["", "_key"]; | params ["", "_key"]; | ||
_key | _key ={{=}} DIK_ESC // ESC pressed while dialog is open, overwrite default behaviour | ||
}];</code> | }];</code> | ||
</dd> | </dd> | ||
</dl> | </dl> |
Revision as of 09:43, 13 May 2022
Description
- Description:
- Adds an event handler to the given display. See User Interface Event Handlers for the full list of event 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.
- Groups:
- GUI Control - Event HandlersEvent Handlers
Syntax
- Syntax:
- display displayAddEventHandler [eventName, code]
- Parameters:
- display: Display
- eventName: String - Event name.
- code: String or Code - The code which gets executed when event is triggered. Returning true in event handler code will override default engine handling for keyboard events.
- Return Value:
- Number - Index of the newly added event handler or -1 if creation failed
Examples
- Example 1:
moduleName_keyDownEHId = findDisplay 46 displayAddEventHandler ["KeyDown", "hint str _this;"];
- Example 2:
moduleName_keyDownEHId = findDisplay 46 displayAddEventHandler ["KeyDown", {hint str _this}];
Additional Information
- See also:
- ListOfKeyCodes disableSerialization displayRemoveAllEventHandlers displayRemoveEventHandler displaySetEventHandler ctrlAddEventHandler UI Event Handlers findDisplay 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 October 30, 2013 - 11:14
- Killzone_Kid
- As of Arma 3 v1.06 ctrlAddEventHandler and displayAddEventHandler support script Code in addition to String [1]
- Posted on March 10, 2014 - 14:52
- Axyl
- From within an Addon, you must assign the events from a spawned script. e.g.
[] spawn { findDisplay 46 displayAddEventHandler ["KeyDown", "_this call my_KeyDownFunctionhandler"]; };
- Posted on January 22, 2016 - 08:15 (UTC)
- Pigneedle
-
Be sure to wait until the main display is initialized before using this command by using:
waitUntil { !isNull (findDisplay 46) };
- Posted on May 28, 2017 - 11:32 (UTC)
- IT07
- use #define if you want the displayEventHandler to use data that is defined in the same file in which the command is executed. However, that does not work if you use String as 'code'. In case of String, use the format command around it.
- Posted on August 7, 2017 - 15:08 (UTC)
- DrSova
- Using KeyUp you can't override default engine action by returning true (Arma3 v1.72)
- Posted on June 26, 2021 - 16:17 (UTC)
- R3vo
-
To prevent a display from getting closed by pressing ESC, add the following event handler.
#include "\a3\ui_f\hpp\definedikcodes.inc" _display displayAddEventHandler ["KeyDown", { params ["", "_key"]; _key == DIK_ESC // ESC pressed while dialog is open, overwrite default behaviour }];