User Interface Event Handlers: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Page lifting)
(format, onJoystickButtom moved to talk for historical keeping)
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOEDITSECTION__
__NOEDITSECTION__
<div style="float: right; margin-left: 1.5em; max-width: 25%;">__TOC__</div>
{{SideTOC}}
User Interface Event handlers allow you to automatically monitor and then execute custom code upon particular UI events being triggered.
'''U'''ser '''I'''nterface '''E'''vent '''H'''andlers allow you to automatically monitor and then execute custom code upon particular UI events being triggered.




Line 16: Line 16:
* '''Fired on:''' Fires when UI container is created, but no action is taken. onLoad event for display fires '''after''' onLoad events for all controls it contains are fired.
* '''Fired on:''' Fires when UI container is created, but no action is taken. onLoad event for display fires '''after''' onLoad events for all controls it contains are fired.
* '''Returns:''' Returns the display or control in format [[Array]].
* '''Returns:''' Returns the display or control in format [[Array]].
<syntaxhighlight lang="cpp">params ["_displayorcontrol"];</syntaxhighlight>




Line 23: Line 24:
* '''Fired on:''' Display is closed, but no controls are destroyed yet.
* '''Fired on:''' Display is closed, but no controls are destroyed yet.
* '''Returns:''' Returns the display and exit code.
* '''Returns:''' Returns the display and exit code.
{{note|onUnload event doesn't fire for RscTitles displays started with [[cutRsc]]}}
<syntaxhighlight lang="cpp">params ["_display", "_exitCode"];</syntaxhighlight>
{{Informative|onUnload event doesn't fire for RscTitles displays started with [[cutRsc]]}}




Line 39: Line 41:
* '''Fired on:''' The mouse pointer enters the control area.
* '''Fired on:''' The mouse pointer enters the control area.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 46: Line 49:
* '''Fired on:''' The mouse pointer exits the control area.
* '''Fired on:''' The mouse pointer exits the control area.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 53: Line 57:
* '''Fired on:''' Input focus is on control. It now begins to accept keyboard input.
* '''Fired on:''' Input focus is on control. It now begins to accept keyboard input.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 60: Line 65:
* '''Fired on:''' Input focus is no longer on control. It no longer accepts keyboard input.
* '''Fired on:''' Input focus is no longer on control. It no longer accepts keyboard input.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 67: Line 73:
* '''Fired on:''' After amount of time given by setTimer function.
* '''Fired on:''' After amount of time given by setTimer function.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 74: Line 81:
* '''Fired on:''' Pressing any keyboard key. Fired before the [[#onKeyUp|onKeyUp]] event.
* '''Fired on:''' Pressing any keyboard key. Fired before the [[#onKeyUp|onKeyUp]] event.
* '''Returns:''' Returns the control, the [[DIK_KeyCodes|keyboard code]] and the state of Shift, Ctrl and Alt.
* '''Returns:''' Returns the control, the [[DIK_KeyCodes|keyboard code]] and the state of Shift, Ctrl and Alt.
<syntaxhighlight lang="cpp">params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"];</syntaxhighlight>




Line 81: Line 89:
* '''Fired on:''' Releasing any keyboard key. Fired after the [[#onKeyDown|onKeyDown]] event.
* '''Fired on:''' Releasing any keyboard key. Fired after the [[#onKeyDown|onKeyDown]] event.
* '''Returns:''' Returns the control, the [[DIK_KeyCodes|keyboard code]] and the state of Shift, Ctrl and Alt.
* '''Returns:''' Returns the control, the [[DIK_KeyCodes|keyboard code]] and the state of Shift, Ctrl and Alt.
<syntaxhighlight lang="cpp">params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"];</syntaxhighlight>




Line 88: Line 97:
* '''Fired on:''' When some readable characters is recognised.
* '''Fired on:''' When some readable characters is recognised.
* '''Returns:''' Returns the control and the char code.
* '''Returns:''' Returns the control and the char code.
<syntaxhighlight lang="cpp">params ["_control", "_charCode"];</syntaxhighlight>




Line 95: Line 105:
* '''Fired on:''' When IME character is recognized (used in Korean and other eastern languages).
* '''Fired on:''' When IME character is recognized (used in Korean and other eastern languages).
* '''Returns:''' Returns the control and the char code.
* '''Returns:''' Returns the control and the char code.
<syntaxhighlight lang="cpp">params ["_control", "_charCode"];</syntaxhighlight>




Line 102: Line 113:
* '''Fired on:''' When partial IME character is recognized (used in Korean and other eastern languages).
* '''Fired on:''' When partial IME character is recognized (used in Korean and other eastern languages).
* '''Returns:''' Returns the control and the char code.
* '''Returns:''' Returns the control and the char code.
 
<syntaxhighlight lang="cpp">params ["_control", "_charCode"];</syntaxhighlight>
 
==== onJoystickButton ====
* '''Priority:''' 3
* '''Use on:''' Control
* '''Fired on:''' Pressing and releasing any joystick button.
* '''Returns:''' Returns the control and the the pressed button.<br />{{note|Not present in Arma 2 or Arma 3}}




Line 116: Line 121:
* '''Fired on:''' Pressing a mouse button. Followed by the [[#onMouseButtonUp|onMouseButtonUp]] event.
* '''Fired on:''' Pressing a mouse button. Followed by the [[#onMouseButtonUp|onMouseButtonUp]] event.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
<syntaxhighlight lang="cpp">params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];</syntaxhighlight>




Line 123: Line 129:
* '''Fired on:''' Releasing a mouse button. Follows the [[#onMouseButtonDown|onMouseButtonDown]] event.
* '''Fired on:''' Releasing a mouse button. Follows the [[#onMouseButtonDown|onMouseButtonDown]] event.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
<syntaxhighlight lang="cpp">params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];</syntaxhighlight>




Line 130: Line 137:
* '''Fired on:''' Pressing and releasing a mouse button.
* '''Fired on:''' Pressing and releasing a mouse button.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
<syntaxhighlight lang="cpp">params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];</syntaxhighlight>




Line 137: Line 145:
* '''Fired on:''' Pressing and releasing a mouse button twice within very short time.
* '''Fired on:''' Pressing and releasing a mouse button twice within very short time.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
* '''Returns:''' Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
<syntaxhighlight lang="cpp">params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];</syntaxhighlight>




Line 144: Line 153:
<hr />
<hr />
* '''Use on:''' Control
* '''Use on:''' Control
* '''Returns:''' Returns the control, the x and y coordinates relative to the controls parent and mouseOver.<br />
* '''Returns:''' Returns the control, the x and y coordinates relative to the controls parent and mouseOver.<br />If the controls parent is its display then x and y will be the same as [[getMousePosition]] else it will be relative to its parent control for instance if inside a [[DialogControls-ControlsGroup|controlsGroup]]
If the controls parent is its display then x and y will be the same as [[getMousePosition]] else it will be relative to its parent control for instance if inside a [[DialogControls-ControlsGroup|controlsGroup]]
<syntaxhighlight lang="cpp">params ["_control", "_xPos", "_yPos", "_mouseOver"];</syntaxhighlight>
<hr />
<hr />
* '''Use on:''' Display
* '''Use on:''' Display
* '''Returns:''' Returns the display, and ''some kind of'' x and y delta position.
* '''Returns:''' Returns the display, and ''some kind of'' x and y delta position.
<syntaxhighlight lang="cpp">params ["_display", "_xPos", "_yPos"];</syntaxhighlight>




==== onMouseHolding ====
==== onMouseHolding ====
* '''Priority:''' 2
* '''Priority:''' 2
* '''Fired on:''' Fires continuously while mouse is not moving with a certain interval.
<hr />
* '''Use on:''' Control
* '''Use on:''' Control
* '''Fired on:''' Fires continuously while mouse is not moving with a certain interval.
* '''Returns:''' Returns the control, the x and y coordinates relative to the controls parent and mouseOver.<br />If the controls parent is its display then x and y will be the same as [[getMousePosition]] else it will be relative to its parent control for instance if inside a [[DialogControls-ControlsGroup|controlsGroup]]
* '''Returns:''' Returns the control, the x and y coordinates and mouseOver. If used with a display, the mouseOver parameter is excluded.
<syntaxhighlight lang="cpp">params ["_control", "_xPos", "_yPos", "_mouseOver"];</syntaxhighlight>
 
<hr />
* '''Use on:''' Display
* '''Returns:''' Returns the display, and ''some kind of'' x and y delta position.
<syntaxhighlight lang="cpp">params ["_display", "_xPos", "_yPos"];</syntaxhighlight>


==== onMouseZChanged ====
==== onMouseZChanged ====
Line 163: Line 178:
* '''Fired on:''' Fires when mouse wheel position is changed. Does not fire on disabled control.
* '''Fired on:''' Fires when mouse wheel position is changed. Does not fire on disabled control.
* '''Returns:''' Returns the display or control and the change of the scrollwheel.
* '''Returns:''' Returns the display or control and the change of the scrollwheel.
<syntaxhighlight lang="cpp">params ["_displayorcontrol", "_scroll"];</syntaxhighlight>




Line 170: Line 186:
* '''Fired on:''' Ask this control if dialog can be closed (used for validation of contained data).
* '''Fired on:''' Ask this control if dialog can be closed (used for validation of contained data).
* '''Returns:''' Returns the control and exit code.
* '''Returns:''' Returns the control and exit code.
<syntaxhighlight lang="cpp">params ["_control", "_exitCode"];</syntaxhighlight>




Line 177: Line 194:
* '''Fired on:''' Destroying control
* '''Fired on:''' Destroying control
* '''Returns:''' Returns the control and exit code.
* '''Returns:''' Returns the control and exit code.
<syntaxhighlight lang="cpp">params ["_control", "_exitCode"];</syntaxhighlight>
{{Cfg ref|end}}
{{Cfg ref|end}}


Line 188: Line 206:
* '''Fired on:''' The attached button action is performed. When returned value is [[true]], button's display remains opened.
* '''Fired on:''' The attached button action is performed. When returned value is [[true]], button's display remains opened.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 204: Line 223:
* '''Fired on:''' The left mouse button is pressed over the button area or a key on the keyboard is pressed.
* '''Fired on:''' The left mouse button is pressed over the button area or a key on the keyboard is pressed.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 209: Line 229:
* '''Priority:''' 1
* '''Priority:''' 1
* '''Use on:''' Button
* '''Use on:''' Button
* '''Fired on:''' The left mouse buttons is released outside the button area and the attached button action is not performed.
* '''Fired on:''' The left mouse button is released outside the button area and the attached button action '''is not performed'''.
* '''Returns:''' Returns control.
* '''Returns:''' Returns control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>
{{Cfg ref|end}}
{{Cfg ref|end}}


Line 222: Line 243:
* '''Fired on:''' The selection in a listbox is changed. The left mouse button has been released and the new selection is fully made.
* '''Fired on:''' The selection in a listbox is changed. The left mouse button has been released and the new selection is fully made.
* '''Returns:''' Returns the control and the selected element index.
* '''Returns:''' Returns the control and the selected element index.
<syntaxhighlight lang="cpp">params ["_control", "_selectedIndex"];</syntaxhighlight>




Line 229: Line 251:
* '''Fired on:''' Selection in XCombo box changed (but value is not stored yet).
* '''Fired on:''' Selection in XCombo box changed (but value is not stored yet).
* '''Returns:''' Returns the control and the selected element index.
* '''Returns:''' Returns the control and the selected element index.
<syntaxhighlight lang="cpp">params ["_control", "_selectedIndex"];</syntaxhighlight>




Line 236: Line 259:
* '''Fired on:''' Double click on some row in listbox.
* '''Fired on:''' Double click on some row in listbox.
* '''Returns:''' Returns the control and the selected element index.
* '''Returns:''' Returns the control and the selected element index.
<syntaxhighlight lang="cpp">params ["_control", "_selectedIndex"];</syntaxhighlight>




Line 243: Line 267:
* '''Fired on:''' Drag & drop operation started.
* '''Fired on:''' Drag & drop operation started.
* '''Returns:''' Returns the control and the selected element index.
* '''Returns:''' Returns the control and the selected element index.
<syntaxhighlight lang="cpp">params ["_control", "_selectedIndex"];</syntaxhighlight>




Line 250: Line 275:
* '''Fired on:''' Drag & drop operation is in progress.
* '''Fired on:''' Drag & drop operation is in progress.
* '''Returns:''' Returns the control and the x and y coordinates.
* '''Returns:''' Returns the control and the x and y coordinates.
<syntaxhighlight lang="cpp">params ["_control", "_xPos", "_yPos"];</syntaxhighlight>




Line 257: Line 283:
* '''Fired on:''' Drag & drop operation finished.
* '''Fired on:''' Drag & drop operation finished.
* '''Returns:''' Returns the control and the x and y coordinates.<br />When the Listbox is inside a ctrlGroup the eventhandler need to be added to the ctrlGroup.
* '''Returns:''' Returns the control and the x and y coordinates.<br />When the Listbox is inside a ctrlGroup the eventhandler need to be added to the ctrlGroup.
<syntaxhighlight lang="cpp">params ["_control", "_xPos", "_yPos"];</syntaxhighlight>
{{Cfg ref|end}}
{{Cfg ref|end}}


Line 268: Line 295:
* '''Fired on:''' Changing the selection in a tree.
* '''Fired on:''' Changing the selection in a tree.
* '''Returns:''' Returns the control and the new selection path.
* '''Returns:''' Returns the control and the new selection path.
<syntaxhighlight lang="cpp">params ["_control", "_selectionPath"];</syntaxhighlight>


==== onTreeLButtonDown ====
==== onTreeLButtonDown ====
Line 274: Line 303:
* '''Fired on:''' Pressing and releasing left mouse button on a tree.
* '''Fired on:''' Pressing and releasing left mouse button on a tree.
* '''Returns:''' Returns the control.
* '''Returns:''' Returns the control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>


==== onTreeDblClick ====
==== onTreeDblClick ====
Line 280: Line 311:
* '''Fired on:''' Pressing and releasing twice on a tree entry.
* '''Fired on:''' Pressing and releasing twice on a tree entry.
* '''Returns:''' Returns the control and the current selection path.
* '''Returns:''' Returns the control and the current selection path.
<syntaxhighlight lang="cpp">params ["_control", "_selectionPath"];</syntaxhighlight>


==== onTreeExpanded ====
==== onTreeExpanded ====
Line 286: Line 319:
* '''Fired on:''' The tree folder structure has been expanded.
* '''Fired on:''' The tree folder structure has been expanded.
* '''Returns:''' Returns the control.
* '''Returns:''' Returns the control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>


==== onTreeCollapsed ====
==== onTreeCollapsed ====
Line 292: Line 327:
* '''Fired on:''' The tree folder structure has been collapsed.
* '''Fired on:''' The tree folder structure has been collapsed.
* '''Returns:''' Returns the control.
* '''Returns:''' Returns the control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>


==== onTreeMouseMove ====
==== onTreeMouseMove ====
Line 298: Line 335:
* '''Fired on:''' Fires continuously while moving the mouse with a certain interval.
* '''Fired on:''' Fires continuously while moving the mouse with a certain interval.
* '''Returns:''' Returns the control.
* '''Returns:''' Returns the control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>


==== onTreeMouseHold ====
==== onTreeMouseHold ====
Line 304: Line 343:
* '''Fired on:''' Fires continuously while mouse is not moving with a certain interval.
* '''Fired on:''' Fires continuously while mouse is not moving with a certain interval.
* '''Returns:''' Returns the control.
* '''Returns:''' Returns the control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 311: Line 351:
* '''Fired on:''' The mouse pointer exits the tree control area
* '''Fired on:''' The mouse pointer exits the tree control area
* '''Returns:''' Returns the control.
* '''Returns:''' Returns the control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>
{{Cfg ref|end}}
{{Cfg ref|end}}


Line 323: Line 364:
* '''Priority:''' ?
* '''Priority:''' ?
* '''Fired on:''' CheckBox checked
* '''Fired on:''' CheckBox checked
* '''Returns:''' ?




Line 332: Line 374:
* '''Fired on:''' Checked state of CheckBox changed.
* '''Fired on:''' Checked state of CheckBox changed.
* '''Returns:''' Returns control and the checked state (0 or 1, not boolean).
* '''Returns:''' Returns control and the checked state (0 or 1, not boolean).
<syntaxhighlight lang="cpp">params ["_control", "_checked"];</syntaxhighlight>




Line 339: Line 382:
* '''Fired on:''' Changed the selection in a checkbox.
* '''Fired on:''' Changed the selection in a checkbox.
* '''Returns:''' Returns the control, the selected element index and the current state.
* '''Returns:''' Returns the control, the selected element index and the current state.
<syntaxhighlight lang="cpp">params ["_control", "_selectedIndex", "_currentState"];</syntaxhighlight>
{{Cfg ref|end}}
{{Cfg ref|end}}


Line 350: Line 394:
* '''Fired on:''' Changed the selection in a toolbox.
* '''Fired on:''' Changed the selection in a toolbox.
* '''Returns:''' Returns the control and the selected element index.
* '''Returns:''' Returns the control and the selected element index.
<syntaxhighlight lang="cpp">params ["_control", "_selectedIndex"];</syntaxhighlight>




Line 357: Line 402:
* '''Fired on:''' Pressing and releasing a HTML link.
* '''Fired on:''' Pressing and releasing a HTML link.
* '''Returns:''' Returns the control and href.
* '''Returns:''' Returns the control and href.
<syntaxhighlight lang="cpp">params ["_control", "_url"];</syntaxhighlight>




Line 364: Line 410:
* '''Fired on:''' Changing the position of a slider.
* '''Fired on:''' Changing the position of a slider.
* '''Returns:''' Returns the control and the change.
* '''Returns:''' Returns the control and the change.
<syntaxhighlight lang="cpp">params ["_control", "_newValue"];</syntaxhighlight>




Line 371: Line 418:
* '''Fired on:''' Moving an object.
* '''Fired on:''' Moving an object.
* '''Returns:''' Returns the control and the offset on the x, y and z axes.
* '''Returns:''' Returns the control and the offset on the x, y and z axes.
<syntaxhighlight lang="cpp">params ["_control", "_offset"];</syntaxhighlight>




Line 378: Line 426:
* '''Fired on:''' Some item in context menu (used now only in new mission editor) was selected.
* '''Fired on:''' Some item in context menu (used now only in new mission editor) was selected.
* '''Returns:''' Returns the control and the command id.
* '''Returns:''' Returns the control and the command id.
<syntaxhighlight lang="cpp">params ["_control", "_commandId"];</syntaxhighlight>




Line 385: Line 434:
* '''Fired on:''' Fires when the map is drawn (can occur more than once per second).
* '''Fired on:''' Fires when the map is drawn (can occur more than once per second).
* '''Returns:''' Returns the map control.
* '''Returns:''' Returns the map control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>




Line 393: Line 443:
* '''Use on:''' Control
* '''Use on:''' Control
* '''Fired on:''' Activated every time the video ends (when looped, handler is executed after every finished loop).
* '''Fired on:''' Activated every time the video ends (when looped, handler is executed after every finished loop).
* '''Returns:''' Returns the control
* '''Returns:''' Returns the control.
<syntaxhighlight lang="cpp">params ["_control"];</syntaxhighlight>
{{Cfg ref|end}}
{{Cfg ref|end}}



Revision as of 11:09, 4 September 2018

Template:SideTOC User Interface Event Handlers allow you to automatically monitor and then execute custom code upon particular UI events being triggered.


Reference List

When using the event names listed below with the ctrlAddEventHandler, ctrlSetEventHandler, displayAddEventHandler or displaySetEventHandler commands, the prefix "on" in the name must be removed (e.g. 'ButtonDown' instead of 'onButtonDown').


Generic events

Template:Cfg ref Template:Cfg ref

onLoad

  • Priority: 1
  • Use on: Display, Control
  • Fired on: Fires when UI container is created, but no action is taken. onLoad event for display fires after onLoad events for all controls it contains are fired.
  • Returns: Returns the display or control in format Array.
params ["_displayorcontrol"];


onUnload

  • Priority: 1
  • Use on: Display
  • Fired on: Display is closed, but no controls are destroyed yet.
  • Returns: Returns the display and exit code.
params ["_display", "_exitCode"];
onUnload event doesn't fire for RscTitles displays started with cutRsc


onChildDestroyed

  • Priority: 1
  • Use on: Display
  • Fired on: Child display is closed.
  • Returns: Returns the display, which child display was closed and exit code.
params ["_display", "_closedChildDisplay", "_exitCode"];


onMouseEnter

  • Priority: 1
  • Use on: Control
  • Fired on: The mouse pointer enters the control area.
  • Returns: Returns control.
params ["_control"];


onMouseExit

  • Priority: 1
  • Use on: Control
  • Fired on: The mouse pointer exits the control area.
  • Returns: Returns control.
params ["_control"];


onSetFocus

  • Priority: 2
  • Use on: Control
  • Fired on: Input focus is on control. It now begins to accept keyboard input.
  • Returns: Returns control.
params ["_control"];


onKillFocus

  • Priority: 2
  • Use on: Control
  • Fired on: Input focus is no longer on control. It no longer accepts keyboard input.
  • Returns: Returns control.
params ["_control"];


onTimer

  • Priority: 3
  • Use on: Control
  • Fired on: After amount of time given by setTimer function.
  • Returns: Returns control.
params ["_control"];


onKeyDown

  • Priority: 2
  • Use on: Display, Control
  • Fired on: Pressing any keyboard key. Fired before the onKeyUp event.
  • Returns: Returns the control, the keyboard code and the state of Shift, Ctrl and Alt.
params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"];


onKeyUp

  • Priority: 2
  • Use on: Display, Control
  • Fired on: Releasing any keyboard key. Fired after the onKeyDown event.
  • Returns: Returns the control, the keyboard code and the state of Shift, Ctrl and Alt.
params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"];


onChar

  • Priority: 2
  • Use on: Control
  • Fired on: When some readable characters is recognised.
  • Returns: Returns the control and the char code.
params ["_control", "_charCode"];


onIMEChar

  • Priority: 2
  • Use on: Control
  • Fired on: When IME character is recognized (used in Korean and other eastern languages).
  • Returns: Returns the control and the char code.
params ["_control", "_charCode"];


onIMEComposition

  • Priority: 2
  • Use on: Control
  • Fired on: When partial IME character is recognized (used in Korean and other eastern languages).
  • Returns: Returns the control and the char code.
params ["_control", "_charCode"];


onMouseButtonDown

  • Priority: 2
  • Use on: Control
  • Fired on: Pressing a mouse button. Followed by the onMouseButtonUp event.
  • Returns: Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];


onMouseButtonUp

  • Priority: 2
  • Use on: Control
  • Fired on: Releasing a mouse button. Follows the onMouseButtonDown event.
  • Returns: Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];


onMouseButtonClick

  • Priority: 2
  • Use on: ListBox, ComboBox, TextBox, Button, ActiveText
  • Fired on: Pressing and releasing a mouse button.
  • Returns: Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];


onMouseButtonDblClick

  • Priority: 2
  • Use on: Control
  • Fired on: Pressing and releasing a mouse button twice within very short time.
  • Returns: Returns the control, the pressed button, the x and y coordinates and the state of Shift, Ctrl and Alt.
params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"];


onMouseMoving

  • Priority: 2
  • Fired on: Fires continuously while moving the mouse with a certain interval.

  • Use on: Control
  • Returns: Returns the control, the x and y coordinates relative to the controls parent and mouseOver.
    If the controls parent is its display then x and y will be the same as getMousePosition else it will be relative to its parent control for instance if inside a controlsGroup
params ["_control", "_xPos", "_yPos", "_mouseOver"];

  • Use on: Display
  • Returns: Returns the display, and some kind of x and y delta position.
params ["_display", "_xPos", "_yPos"];


onMouseHolding

  • Priority: 2
  • Fired on: Fires continuously while mouse is not moving with a certain interval.

  • Use on: Control
  • Returns: Returns the control, the x and y coordinates relative to the controls parent and mouseOver.
    If the controls parent is its display then x and y will be the same as getMousePosition else it will be relative to its parent control for instance if inside a controlsGroup
params ["_control", "_xPos", "_yPos", "_mouseOver"];

  • Use on: Display
  • Returns: Returns the display, and some kind of x and y delta position.
params ["_display", "_xPos", "_yPos"];

onMouseZChanged

  • Priority: 2
  • Use on: Display, Control
  • Fired on: Fires when mouse wheel position is changed. Does not fire on disabled control.
  • Returns: Returns the display or control and the change of the scrollwheel.
params ["_displayorcontrol", "_scroll"];


onCanDestroy

  • Priority: 3
  • Use on: Control
  • Fired on: Ask this control if dialog can be closed (used for validation of contained data).
  • Returns: Returns the control and exit code.
params ["_control", "_exitCode"];


onDestroy

  • Priority: 3
  • Use on: Control
  • Fired on: Destroying control
  • Returns: Returns the control and exit code.
params ["_control", "_exitCode"];

Template:Cfg ref


Button events

Template:Cfg ref Template:Cfg ref

onButtonClick

  • Priority: 1
  • Use on: Button
  • Fired on: The attached button action is performed. When returned value is true, button's display remains opened.
  • Returns: Returns control.
params ["_control"];


onButtonDblClick

  • Priority: ?
  • Use on: Button
  • Fired on: button double click?
  • Returns: ?


onButtonDown

  • Priority: 1
  • Use on: Button
  • Fired on: The left mouse button is pressed over the button area or a key on the keyboard is pressed.
  • Returns: Returns control.
params ["_control"];


onButtonUp

  • Priority: 1
  • Use on: Button
  • Fired on: The left mouse button is released outside the button area and the attached button action is not performed.
  • Returns: Returns control.
params ["_control"];

Template:Cfg ref


Listbox events

Template:Cfg ref Template:Cfg ref

onLBSelChanged

  • Priority: 2
  • Use on: Listbox, Combobox
  • Fired on: The selection in a listbox is changed. The left mouse button has been released and the new selection is fully made.
  • Returns: Returns the control and the selected element index.
params ["_control", "_selectedIndex"];


onLBListSelChanged

  • Priority: 2
  • Use on: Listbox
  • Fired on: Selection in XCombo box changed (but value is not stored yet).
  • Returns: Returns the control and the selected element index.
params ["_control", "_selectedIndex"];


onLBDblClick

  • Priority: 2
  • Use on: Listbox
  • Fired on: Double click on some row in listbox.
  • Returns: Returns the control and the selected element index.
params ["_control", "_selectedIndex"];


onLBDrag

  • Priority: 2
  • Use on: Listbox
  • Fired on: Drag & drop operation started.
  • Returns: Returns the control and the selected element index.
params ["_control", "_selectedIndex"];


onLBDragging

  • Priority: 2
  • Use on: Listbox
  • Fired on: Drag & drop operation is in progress.
  • Returns: Returns the control and the x and y coordinates.
params ["_control", "_xPos", "_yPos"];


onLBDrop

  • Priority: 2
  • Use on: Listbox, Combobox, Textbox, ActiveText, Button
  • Fired on: Drag & drop operation finished.
  • Returns: Returns the control and the x and y coordinates.
    When the Listbox is inside a ctrlGroup the eventhandler need to be added to the ctrlGroup.
params ["_control", "_xPos", "_yPos"];

Template:Cfg ref


Tree events

Template:Cfg ref Template:Cfg ref

onTreeSelChanged

  • Priority: 2
  • Use on: Tree
  • Fired on: Changing the selection in a tree.
  • Returns: Returns the control and the new selection path.
params ["_control", "_selectionPath"];


onTreeLButtonDown

  • Priority: 2
  • Use on: Tree
  • Fired on: Pressing and releasing left mouse button on a tree.
  • Returns: Returns the control.
params ["_control"];


onTreeDblClick

  • Priority: 2
  • Use on: Tree
  • Fired on: Pressing and releasing twice on a tree entry.
  • Returns: Returns the control and the current selection path.
params ["_control", "_selectionPath"];


onTreeExpanded

  • Priority: 3
  • Use on: Tree
  • Fired on: The tree folder structure has been expanded.
  • Returns: Returns the control.
params ["_control"];


onTreeCollapsed

  • Priority: 3
  • Use on: Tree
  • Fired on: The tree folder structure has been collapsed.
  • Returns: Returns the control.
params ["_control"];


onTreeMouseMove

  • Priority: 2
  • Use on: Tree
  • Fired on: Fires continuously while moving the mouse with a certain interval.
  • Returns: Returns the control.
params ["_control"];


onTreeMouseHold

  • Priority: 2
  • Use on: Tree
  • Fired on: Fires continuously while mouse is not moving with a certain interval.
  • Returns: Returns the control.
params ["_control"];


onTreeMouseExit

  • Priority: 2
  • Use on: Tree
  • Fired on: The mouse pointer exits the tree control area
  • Returns: Returns the control.
params ["_control"];

Template:Cfg ref


Checkbox events

Template:Cfg ref Template:Cfg ref

onChecked

  • Use on: Checkbox
  • Priority: ?
  • Fired on: CheckBox checked
  • Returns: ?


onCheckedChanged

  • Priority: ?
  • Use on: Checkbox
  • Fired on: Checked state of CheckBox changed.
  • Returns: Returns control and the checked state (0 or 1, not boolean).
params ["_control", "_checked"];


onCheckBoxesSelChanged

  • Priority: 2
  • Use on: Checkbox
  • Fired on: Changed the selection in a checkbox.
  • Returns: Returns the control, the selected element index and the current state.
params ["_control", "_selectedIndex", "_currentState"];

Template:Cfg ref


Misc. events

Template:Cfg ref Template:Cfg ref

onToolBoxSelChanged

  • Priority: 2
  • Use on: Toolbox
  • Fired on: Changed the selection in a toolbox.
  • Returns: Returns the control and the selected element index.
params ["_control", "_selectedIndex"];


onHTMLLink

  • Priority: 2
  • Use on: HTML
  • Fired on: Pressing and releasing a HTML link.
  • Returns: Returns the control and href.
params ["_control", "_url"];


onSliderPosChanged

  • Priority: 2
  • Use on: Slider
  • Fired on: Changing the position of a slider.
  • Returns: Returns the control and the change.
params ["_control", "_newValue"];


onObjectMoved

  • Priority: 2
  • Use on: Object
  • Fired on: Moving an object.
  • Returns: Returns the control and the offset on the x, y and z axes.
params ["_control", "_offset"];


onMenuSelected

  • Priority: 2
  • Use on: Context menu
  • Fired on: Some item in context menu (used now only in new mission editor) was selected.
  • Returns: Returns the control and the command id.
params ["_control", "_commandId"];


onDraw

  • Priority: ?
  • Use on: Map
  • Fired on: Fires when the map is drawn (can occur more than once per second).
  • Returns: Returns the map control.
params ["_control"];


onVideoStopped

  • Priority: 2
  • Use on: Control
  • Fired on: Activated every time the video ends (when looped, handler is executed after every finished loop).
  • Returns: Returns the control.
params ["_control"];

Template:Cfg ref


Event parameters

The events handlers receive parameters in the _this variable. Each event passes a different set of parameters (listed in the table above) in an array. The control or display that the event was assigned to is always found in _this select 0.


Scope

Logo A1 black.png1.00 In ArmA, most control-specific events work for controls and do not work for displays. The two exceptions being: onKeyDown and onKeyUp.
Logo A2.png1.00 Since Arma 2, most control-specific events now work for both displays and controls.


Defining events

User Interface Event Handlers can be assigned in two ways: via class property definitions or via scripting commands.


Class defined events

Events can be defined in the Dialog (display) or Control classes (in config.cpp or description.ext). The event property value (string) is executed as a line of code.

An example line (this would be put within a control or dialog class):

onMouseDown = "hint str _this";

Full Example:

class RscControlsGroup {
	type	= 15;
	idc		= -1;
	style	=  0;
	x = 0;
	y = 0;
	w = 1;
	h = 1;

	class VScrollbar {
		color[]				= { 1, 1, 1, 1 };
		width				= 0.021;
		autoScrollSpeed		= -1;
		autoScrollDelay		= 5;
		autoScrollRewind	= 0;
	};

	class HScrollbar {
		color[]	= { 1, 1, 1, 1 };
		height	= 0.028;
	};

	
	class ScrollBar {	// >= Arma 2
		color[]			= { 1, 1, 1, 0.6 };
		colorActive[]	= { 1, 1, 1, 1 };
		colorDisabled[]	= { 1, 1, 1, 0.3 };
		thumb			= "#(argb,8,8,3)color(1,1,1,1)";
		arrowEmpty		= "#(argb,8,8,3)color(1,1,1,1)";
		arrowFull		= "#(argb,8,8,3)color(1,1,1,1)";
		border			= "#(argb,8,8,3)color(1,1,1,1)";
	};

	class Controls {};
};

class mouseHandler: RscControlsGroup {
	onMouseHolding		= "[0,_this] call myEventFunction";
	onMouseButtonDown	= "[1,_this] call myEventFunction";
	onMouseButtonUp		= "[2,_this] call myEventFunction";
	onMouseZChanged		= "[3,_this] call myEventFunction";
	onMouseEnter		= "[4,_this] call myEventFunction";
	idc = 123;
	x = 0.0;
	y = 0.0;
	w = 1.0;
	h = 1.0;
	colorBackground[] = { 0.2, 0.0, 0.0, 0.0 };
};


Script defined events

These events can also be given to dialogs/controls using the ctrlSetEventHandler scripting command. For the event handler to be called enable the control using the ctrlEnable scripting command.

// adding event handler
(findDisplay 46) displayAddEventHandler ["keyDown", "_this call functionName_keyDown"];

// function definition
functionName_keyDown = {
	params ["_ctrl", "_dikCode", "_shift", "_ctrlKey", "_alt"];
	private _handled = false;

	if (!_shift && !_ctrlKey && !_alt) then {
		if (_dikCode in (actionKeys "NetworkStats")) then {
			[] execVM "path\script.sqf";
			_handled = true;
		};
	};
	_handled;
};