fn_processCuratorKey.sqf 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Name: cTab_fnc_translateUserMarker
  3. Author(s):
  4. michail-nikolaev (nkey, TFAR)
  5. Description:
  6. For a given curator key press event, find a matching key handler that was registered with CBA's keybind system. If a match was found, execute the corresponding CBA key handler event.
  7. Parameters:
  8. 0: ARRAY - KeyDown / KeyUp event attributes
  9. 1: STRING - "keyDown" or "keyUp"
  10. Returns:
  11. BOOLEAN - If event was found and executed upon
  12. Example:
  13. (findDisplay 312) displayAddEventHandler ["KeyDown", "[_this, 'keydown'] call cTab_fnc_processCuratorKey"];
  14. (findDisplay 312) displayAddEventHandler ["KeyUp", "[_this, 'keyup'] call cTab_fnc_processCuratorKey"];
  15. */
  16. private ["_keys", "_pressed", "_result"];
  17. _pressed = _this select 0;
  18. _result = false;
  19. _processKeys = {
  20. private ["_mods","_key_pressed","_handler"];
  21. if ([_key, "ctab_"] call CBA_fnc_find == 0) then {
  22. _key_pressed = _value select 0;
  23. _mods = _value select 1;
  24. _handler = _value select 2;
  25. if ((_key_pressed == _pressed select 1) and {(_mods select 0) isEqualTo (_pressed select 2)} and {(_mods select 1) isEqualTo (_pressed select 3)} and {(_mods select 2) isEqualTo (_pressed select 4)}) exitWith {
  26. _result = call _handler;
  27. };
  28. };
  29. };
  30. [if ((_this select 1) isEqualTo "keyup") then {CBA_events_keyhandlers_up} else {CBA_events_keyhandlers_down}, _processKeys] call CBA_fnc_hashEachPair;
  31. _result;