displayAddEventHandler: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Add ctrlAddEventHandler magic variables) |
Lou Montana (talk | contribs) m (Text replacement - "IT07" to "Nelis.75733126") |
||
Line 58: | Line 58: | ||
{{Note | {{Note | ||
|user= | |user= Nelis.75733126 | ||
|timestamp= 20170528113200 | |timestamp= 20170528113200 | ||
|text= use #define if you want the displayEventHandler to use data that is defined in the same file in which the command is executed. | |text= use #define if you want the displayEventHandler to use data that is defined in the same file in which the command is executed. |
Revision as of 18:00, 16 April 2024
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 1.06 Code - the code which gets executed when event is triggered. Returning true in event handler code will override default engine handling for keyboard events.
Several Magic Variables are available:
- Event Handler parameters are accessible via _this
- The Event Handler type is available as _thisEvent
- The Event Handler index is available as _thisEventHandler
- Return Value:
- Number - index of the newly added event handler or -1 if creation failed
Examples
- Example 1:
- Example 2:
Additional Information
- See also:
- disableSerialization displayRemoveAllEventHandlers displayRemoveEventHandler displaySetEventHandler ctrlAddEventHandler UI Event Handlers findDisplay DIK Key Codes 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 Mar 10, 2014 - 14:52 (UTC)
-
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 Jan 22, 2016 - 08:15 (UTC)
-
Be sure to wait until the main display is initialized before using this command by using:
- Posted on May 28, 2017 - 11:32 (UTC)
- 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 Aug 07, 2017 - 15:08 (UTC)
-
Using KeyUp you can't override default engine action by returning true
- Posted on Jun 26, 2021 - 16:17 (UTC)
- To prevent a display from getting closed by pressing ESC, add the following event handler.