{"name":"inGameUISetEventHandler","operator":null,"title":"inGameUISetEventHandler","type":"command","url":"https://community.bistudio.com/wiki/inGameUISetEventHandler","revid":378923,"updated":"2026-08-14T20:25:31Z","groups":["GUI Control - Event Handlers","Event Handlers","Interaction"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":"local","server_exec":false},"exec":null,"description":"Sets given event handler of in-game UI. If EH function returns true, performed action is overridden. Event handlers available are:\n- \"PrevAction\" - mouse scroll up\n- \"Action\" - action key press\n- \"NextAction\" - mouse scroll down\nIn order to remove a previously added event handler, set it again with an empty *code* string `\"\"`.\n\n> [!NOTE]\n> **Since Arma 3 v2.22 consider using hideActions**\n\n> [!IMPORTANT]\n> This is a \"set\" command, which means event handlers are not stackable and will replace previously set event handlers of the same type.\n\n> [!NOTE]\n> **Arma 3:** Since Arma 3 v1.50 the event handler receives an array of the selected/activated action's arguments in `_this` variable:\n>\n> ```sqf\n> params [\"_target\", \"_caller\", \"_index\", \"_engineName\", \"_text\", \"_priority\", \"_showWindow\", \"_hideOnUse\", \"_shortcut\", \"_visibleMenu\", \"_eventName\"];\n> ```\n>\n> - _target: Object - target object to which action is attached\n> - _caller: Object - caller object, basically player\n> - _index: Number - index of the action in action menu (0 - top most)\n> - _engineName: String - engine based action name (\"User\" for user added actions)\n> - _text: String - localized action plain text as seen by the caller\n> - _priority: Number - action *priority* value\n> - _showWindow: Boolean - action *showWindow* value\n> - _hideOnUse: Boolean - action *hideOnUse* value\n> - _shortcut: String - action *shortcut* name or \"\"\n> - _visibleMenu: Boolean - action menu visibility - on first scroll or action press the menu is still invisible, the menu is shown but no action is performed\n> - _eventName: String - event name","syntaxes":[{"syntax":"inGameUISetEventHandler [handlerName, code]","since":null,"effect":null,"exec":null,"params":[{"name":"handlerName","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"handlerName: String"},{"name":"code","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"code: String"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"[handlerName, code]","types":["Array"]}}],"examples":[{"text":"```sqf\ninGameUISetEventHandler [\"Action\", \"hint 'Lights, Camera, Action!'; true\"];\nsleep 10;\ninGameUISetEventHandler [\"Action\", \"\"]; // removes the \"Action\" EH\n```","code":["inGameUISetEventHandler [\"Action\", \"hint 'Lights, Camera, Action!'; true\"];\nsleep 10;\ninGameUISetEventHandler [\"Action\", \"\"]; // removes the \"Action\" EH"]},{"text":"```sqf\ninGameUISetEventHandler [\"PrevAction\", \"hint str _this; false\"];\ninGameUISetEventHandler [\"NextAction\", \"hint str _this; false\"];\ninGameUISetEventHandler [\"Action\", \"hint str _this; false\"];\n```","code":["inGameUISetEventHandler [\"PrevAction\", \"hint str _this; false\"];\ninGameUISetEventHandler [\"NextAction\", \"hint str _this; false\"];\ninGameUISetEventHandler [\"Action\", \"hint str _this; false\"];"]},{"text":"Deny any weapon disassembly:\n\n```sqf\ninGameUISetEventHandler [\"Action\", \"\n    if (_this select 3 == 'DisAssemble') then {\n        hint 'You are not allowed to do this';\n        true\n    }\n\"];\n```","code":["inGameUISetEventHandler [\"Action\", \"\n\tif (_this select 3 == 'DisAssemble') then {\n\t\thint 'You are not allowed to do this';\n\t\ttrue\n\t}\n\"];"]},{"text":"Detect explosive/mine placement:\n\n```sqf\nprivate _onMagazineUse = '\n    params [\"_target\", \"\", \"\", \"_action\", \"\", \"\", \"\", \"\", \"\", \"\", \"_event\"];\n    if (_action == \"UseMagazine\") then {\n        if (_event == \"Action\") then {\n            _target spawn {\n                waitUntil {!(all_magazines isEqualTo magazines _this)};\n                {\n                    0 = all_magazines deleteAt (all_magazines find _x);\n                } count magazines _this;\n                hint format [\"Magazine Used: %1\", all_magazines select 0];\n            };\n        } else {\n            all_magazines = magazines _target;\n        };\n    };\n    false\n';\ninGameUISetEventHandler [\"PrevAction\", _onMagazineUse];\ninGameUISetEventHandler [\"NextAction\", _onMagazineUse];\ninGameUISetEventHandler [\"Action\", _onMagazineUse];\n```","code":["private _onMagazineUse = '\n\tparams [\"_target\", \"\", \"\", \"_action\", \"\", \"\", \"\", \"\", \"\", \"\", \"_event\"];\n\tif (_action == \"UseMagazine\") then {\n\t\tif (_event == \"Action\") then {\n\t\t\t_target spawn {\n\t\t\t\twaitUntil {!(all_magazines isEqualTo magazines _this)};\n\t\t\t\t{\n\t\t\t\t\t0 = all_magazines deleteAt (all_magazines find _x);\n\t\t\t\t} count magazines _this;\n\t\t\t\thint format [\"Magazine Used: %1\", all_magazines select 0];\n\t\t\t};\n\t\t} else {\n\t\t\tall_magazines = magazines _target;\n\t\t};\n\t};\n\tfalse\n';\ninGameUISetEventHandler [\"PrevAction\", _onMagazineUse];\ninGameUISetEventHandler [\"NextAction\", _onMagazineUse];\ninGameUISetEventHandler [\"Action\", _onMagazineUse];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["isActionMenuVisible","addEventHandler","ctrlAddEventHandler","displayAddEventHandler","actionIDs","actionParams","addAction","setUserActionText","showHUD","inputAction","removeAction","removeAllActions","action","enableWeaponDisassembly"],"notes":[{"user":"AgentRev","date":"2016-05-12T20:51:00Z","text":"In case of the \"Action\" event, (*_showWindow* || *_visibleMenu*) also denotes if the action is performed or not. For example, if the action menu is closed or fading off, pressing Spacebar will bring it up and trigger an \"Action\" event; in that case, *_visibleMenu* is false. But if the action menu is open, and Spacebar is pressed to perform the selected action, then *_visibleMenu* will be true. If *_showWindow* is true, then it means the action was performed, regardless of *_visibleMenu*."}],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Event Handlers","Command Group: GUI Control - Event Handlers","Command Group: Interaction","Introduced with Armed Assault version 1.00","Scripting Commands","Scripting Commands: Local Effect","Take On Helicopters: Scripting Commands"]}