From 05f6c8b403d2e0e5ef9026a9b0aaae6b178de4e1 Mon Sep 17 00:00:00 2001 From: "eugene.tretyak" Date: Wed, 28 Jul 2021 22:30:09 +0300 Subject: [PATCH 1/3] Optional single click mode for Item Context Menu --- addons/ui/fnc_openItemContextMenu.sqf | 27 +++++++++++++++++++++------ addons/ui/initSettings.sqf | 12 ++++++++++++ addons/ui/stringtable.xml | 24 ++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/addons/ui/fnc_openItemContextMenu.sqf b/addons/ui/fnc_openItemContextMenu.sqf index 3fd9328bd7..7f46aba6fb 100644 --- a/addons/ui/fnc_openItemContextMenu.sqf +++ b/addons/ui/fnc_openItemContextMenu.sqf @@ -131,12 +131,10 @@ _list setVariable [QFUNC(activate), { }; }]; -_list ctrlAddEventHandler ["lbDblClick", { - params ["_list"]; - _this call (_list getVariable QFUNC(activate)); -}]; - -_list ctrlAddEventHandler ["KeyDown", { +// Selecting context menu interaction mode: +// Mouse double click + keyboard (Default) +private _optionSelectHandlerType = "LBDblClick"; +private _optionListKeyHandlerCode = { params ["_list", "_key"]; if (_key in [DIK_RETURN, DIK_NUMPADENTER]) then { [_list getVariable QFUNC(activate), [_list, lbCurSel _list]] call CBA_fnc_execNextFrame; @@ -144,7 +142,24 @@ _list ctrlAddEventHandler ["KeyDown", { // Set focus on background to prevent the inventory menu from auto closing. ctrlSetFocus (ctrlParent _list displayCtrl IDC_FG_GROUND_TAB); }; +}; + +if (GVAR(contextMenuSelectionMode) == 1) then { + // Mouse only (single click) mode + // keyboard's Up/Down events intercepted to prevent LBSelChanged event + _optionSelectHandlerType = "LBSelChanged"; + _optionListKeyHandlerCode = { + params ["", "_key"]; + if !(_key in [DIK_UP, DIK_DOWN]) exitWith {}; + true + }; +}; + +_list ctrlAddEventHandler [_optionSelectHandlerType, { + params ["_list"]; + _this call (_list getVariable QFUNC(activate)); }]; +_list ctrlAddEventHandler ["KeyDown", _optionListKeyHandlerCode]; // --- // Set context menu position and size. diff --git a/addons/ui/initSettings.sqf b/addons/ui/initSettings.sqf index 131e9822b2..1f751b2327 100644 --- a/addons/ui/initSettings.sqf +++ b/addons/ui/initSettings.sqf @@ -26,3 +26,15 @@ [1, 10, 4, 1], // default value 2 // global ] call CBA_fnc_addSetting; + +[ + QGVAR(contextMenuSelectionMode), + "LIST", + [LLSTRING(ContextMenuSelectionMode), LLSTRING(ContextMenuSelectionModeTooltip)], + [LELSTRING(main,DisplayName), LLSTRING(Category)], + [[0,1], [ + [LLSTRING(ContextMenuMouseAndKeyboard), LLSTRING(ContextMenuMouseAndKeyboardTooltip)], + [LLSTRING(ContextMenuMouseOnly), LLSTRING(ContextMenuMouseOnlyTooltip)] + ], 0], + 2 +] call CBA_fnc_addSetting; diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index 4641a4584b..47e9316b29 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -190,6 +190,30 @@ Текстовая информация для игрока. Comentarios textuales para el jugador + + Item Context Menu Selection Type + Режим контекстного меню предметов + + + Sets selection mode of the options in the inventory item context menu (e.g. attachements options). + Задает способ выбора опций в контекстом меню предметов в инвентаре (например, режим работы лазера и фонарика). + + + Double Click + Keyboard + Двойной клик + Клавиатура + + + Selects option by double click. Keyboard allows to focus (arrow up and down keys) and select (enter key) option. + Двойной клик для выбора опции. Клавиатура также позволяет выбрать (стрелки вверх и вниз) и применить (ввод) опцию. + + + Single Click + Одиночный клик + + + Selects option by single click. Keyboard selection is disabled. + Одиночный клик для выбора опции. Клавиатура не поддерживается. + Show all missions Alle Missionen anzeigen From 3e16cca6364fdfe3bc60dce95ae689f99cad9b00 Mon Sep 17 00:00:00 2001 From: "eugene.tretyak" Date: Tue, 3 Aug 2021 13:05:13 +0300 Subject: [PATCH 2/3] Add single frame delay to apply action This will highlight selected option at least for 1 frame --- addons/ui/fnc_openItemContextMenu.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/ui/fnc_openItemContextMenu.sqf b/addons/ui/fnc_openItemContextMenu.sqf index 7f46aba6fb..b23fea46e8 100644 --- a/addons/ui/fnc_openItemContextMenu.sqf +++ b/addons/ui/fnc_openItemContextMenu.sqf @@ -156,8 +156,10 @@ if (GVAR(contextMenuSelectionMode) == 1) then { }; _list ctrlAddEventHandler [_optionSelectHandlerType, { - params ["_list"]; - _this call (_list getVariable QFUNC(activate)); + [{ + params ["_list"]; + _this call (_list getVariable QFUNC(activate)); + }, _this] call CBA_fnc_execNextFrame; }]; _list ctrlAddEventHandler ["KeyDown", _optionListKeyHandlerCode]; From cc6b9800d51de1548812369347e9280460c8a717 Mon Sep 17 00:00:00 2001 From: "eugene.tretyak" Date: Tue, 3 Aug 2021 21:54:41 +0300 Subject: [PATCH 3/3] Removed settings and make single click the only way of the interaction --- addons/ui/fnc_openItemContextMenu.sqf | 33 ++++++--------------------- addons/ui/initSettings.sqf | 12 ---------- addons/ui/stringtable.xml | 24 ------------------- 3 files changed, 7 insertions(+), 62 deletions(-) diff --git a/addons/ui/fnc_openItemContextMenu.sqf b/addons/ui/fnc_openItemContextMenu.sqf index b23fea46e8..283743cbfc 100644 --- a/addons/ui/fnc_openItemContextMenu.sqf +++ b/addons/ui/fnc_openItemContextMenu.sqf @@ -131,37 +131,18 @@ _list setVariable [QFUNC(activate), { }; }]; -// Selecting context menu interaction mode: -// Mouse double click + keyboard (Default) -private _optionSelectHandlerType = "LBDblClick"; -private _optionListKeyHandlerCode = { - params ["_list", "_key"]; - if (_key in [DIK_RETURN, DIK_NUMPADENTER]) then { - [_list getVariable QFUNC(activate), [_list, lbCurSel _list]] call CBA_fnc_execNextFrame; - - // Set focus on background to prevent the inventory menu from auto closing. - ctrlSetFocus (ctrlParent _list displayCtrl IDC_FG_GROUND_TAB); - }; -}; - -if (GVAR(contextMenuSelectionMode) == 1) then { - // Mouse only (single click) mode - // keyboard's Up/Down events intercepted to prevent LBSelChanged event - _optionSelectHandlerType = "LBSelChanged"; - _optionListKeyHandlerCode = { - params ["", "_key"]; - if !(_key in [DIK_UP, DIK_DOWN]) exitWith {}; - true - }; -}; - -_list ctrlAddEventHandler [_optionSelectHandlerType, { +_list ctrlAddEventHandler ["LBSelChanged", { [{ params ["_list"]; _this call (_list getVariable QFUNC(activate)); }, _this] call CBA_fnc_execNextFrame; }]; -_list ctrlAddEventHandler ["KeyDown", _optionListKeyHandlerCode]; +_list ctrlAddEventHandler ["KeyDown", { + params ["", "_key"]; + // keyboard's Up/Down events intercepted to prevent LBSelChanged event + if !(_key in [DIK_UP, DIK_DOWN]) exitWith {}; + true +}]; // --- // Set context menu position and size. diff --git a/addons/ui/initSettings.sqf b/addons/ui/initSettings.sqf index 1f751b2327..131e9822b2 100644 --- a/addons/ui/initSettings.sqf +++ b/addons/ui/initSettings.sqf @@ -26,15 +26,3 @@ [1, 10, 4, 1], // default value 2 // global ] call CBA_fnc_addSetting; - -[ - QGVAR(contextMenuSelectionMode), - "LIST", - [LLSTRING(ContextMenuSelectionMode), LLSTRING(ContextMenuSelectionModeTooltip)], - [LELSTRING(main,DisplayName), LLSTRING(Category)], - [[0,1], [ - [LLSTRING(ContextMenuMouseAndKeyboard), LLSTRING(ContextMenuMouseAndKeyboardTooltip)], - [LLSTRING(ContextMenuMouseOnly), LLSTRING(ContextMenuMouseOnlyTooltip)] - ], 0], - 2 -] call CBA_fnc_addSetting; diff --git a/addons/ui/stringtable.xml b/addons/ui/stringtable.xml index 47e9316b29..4641a4584b 100644 --- a/addons/ui/stringtable.xml +++ b/addons/ui/stringtable.xml @@ -190,30 +190,6 @@ Текстовая информация для игрока. Comentarios textuales para el jugador - - Item Context Menu Selection Type - Режим контекстного меню предметов - - - Sets selection mode of the options in the inventory item context menu (e.g. attachements options). - Задает способ выбора опций в контекстом меню предметов в инвентаре (например, режим работы лазера и фонарика). - - - Double Click + Keyboard - Двойной клик + Клавиатура - - - Selects option by double click. Keyboard allows to focus (arrow up and down keys) and select (enter key) option. - Двойной клик для выбора опции. Клавиатура также позволяет выбрать (стрелки вверх и вниз) и применить (ввод) опцию. - - - Single Click - Одиночный клик - - - Selects option by single click. Keyboard selection is disabled. - Одиночный клик для выбора опции. Клавиатура не поддерживается. - Show all missions Alle Missionen anzeigen