From 13a25be08f0c81a759076907d7950baf4f2c3ef2 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 3 Oct 2019 19:46:12 +0300 Subject: SL-6109 Better menu accelerator support and slight reorganization --- indra/newview/llsetkeybinddialog.cpp | 298 +++++++++++++++++++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 indra/newview/llsetkeybinddialog.cpp (limited to 'indra/newview/llsetkeybinddialog.cpp') diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp new file mode 100644 index 0000000000..0ad71cb372 --- /dev/null +++ b/indra/newview/llsetkeybinddialog.cpp @@ -0,0 +1,298 @@ +/** + * @file llsetkeybinddialog.cpp + * @brief LLSetKeyBindDialog class implementation. + * + * $LicenseInfo:firstyear=2019&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2019, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llsetkeybinddialog.h" + +//#include "llkeyboard.h" + +#include "llbutton.h" +#include "llcheckboxctrl.h" +#include "lleventtimer.h" +#include "llfocusmgr.h" + +class LLSetKeyBindDialog::Updater : public LLEventTimer +{ +public: + + typedef boost::function callback_t; + + Updater(callback_t cb, F32 period, MASK mask) + :LLEventTimer(period), + mMask(mask), + mCallback(cb) + { + mEventTimer.start(); + } + + virtual ~Updater(){} + +protected: + BOOL tick() + { + mCallback(mMask); + // Deletes itseft after execution + return TRUE; + } + +private: + MASK mMask; + callback_t mCallback; +}; + +LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) + : LLModalDialog(key), + pParent(NULL), + mKeyFilterMask(DEFAULT_KEY_FILTER), + pUpdater(NULL) +{ +} + +LLSetKeyBindDialog::~LLSetKeyBindDialog() +{ +} + +//virtual +BOOL LLSetKeyBindDialog::postBuild() +{ + childSetAction("SetEmpty", onBlank, this); + childSetAction("Default", onDefault, this); + childSetAction("Cancel", onCancel, this); + getChild("Cancel")->setFocus(TRUE); + + pCheckBox = getChild("ignore_masks"); + + gFocusMgr.setKeystrokesOnly(TRUE); + + return TRUE; +} + +//virtual +void LLSetKeyBindDialog::onClose(bool app_quiting) +{ + if (pParent) + { + pParent->onCancelKeyBind(); + pParent = NULL; + } + if (pUpdater) + { + // Doubleclick timer has't fired, delete it + delete pUpdater; + pUpdater = NULL; + } + LLModalDialog::onClose(app_quiting); +} + +//virtual +void LLSetKeyBindDialog::draw() +{ + LLRect local_rect; + drawFrustum(local_rect, this, (LLView*)getDragHandle(), hasFocus()); + LLModalDialog::draw(); +} + +void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) +{ + pParent = parent; + setFrustumOrigin(parent); + mKeyFilterMask = key_mask; + + LLTextBase *text_ctrl = getChild("descritption"); + + std::string input; + if ((key_mask & ALLOW_MOUSE) != 0) + { + input = getString("mouse"); + } + if ((key_mask & ALLOW_KEYS) != 0) + { + if (!input.empty()) + { + input += ", "; + } + input += getString("keyboard"); + } + text_ctrl->setTextArg("[INPUT]", input); + + bool can_ignore_masks = (key_mask & CAN_IGNORE_MASKS) != 0; + pCheckBox->setVisible(can_ignore_masks); + pCheckBox->setValue(false); +} + +BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) +{ + if ((key == 'Q' && mask == MASK_CONTROL) + || key == KEY_ESCAPE) + { + closeFloater(); + return TRUE; + } + + if (key == KEY_DELETE) + { + setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); + closeFloater(); + return FALSE; + } + + // forbidden keys + if (key == KEY_NONE + || key == KEY_RETURN + || key == KEY_BACKSPACE) + { + return FALSE; + } + + if ((mKeyFilterMask & ALLOW_MASKS) == 0 + && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) + { + // mask by themself are not allowed + return FALSE; + } + else if ((mKeyFilterMask & ALLOW_KEYS) == 0) + { + // basic keys not allowed + return FALSE; + } + else if ((mKeyFilterMask & ALLOW_MASK_KEYS) == 0 && mask != 0) + { + // masked keys not allowed + return FALSE; + } + + setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); + closeFloater(); + return TRUE; +} + +BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) +{ + BOOL result = FALSE; + if (!pParent) + { + // we already processed 'down' event, this is 'up', consume + closeFloater(); + result = TRUE; + } + if (!result && clicktype == CLICK_LEFT) + { + // try handling buttons first + if (down) + { + result = LLView::handleMouseDown(x, y, mask); + } + else + { + result = LLView::handleMouseUp(x, y, mask); + } + if (result) + { + setFocus(TRUE); + gFocusMgr.setKeystrokesOnly(TRUE); + } + // ignore selection related combinations + else if (down && (mask & (MASK_SHIFT | MASK_CONTROL)) == 0) + { + // this can be a double click, wait a bit; + if (!pUpdater) + { + // Note: default doubleclick time is 500ms, but can stretch up to 5s + pUpdater = new Updater(boost::bind(&onClickTimeout, this, _1), 0.7f, mask); + result = TRUE; + } + } + } + + if (!result + && (clicktype != CLICK_LEFT) // subcases were handled above + && ((mKeyFilterMask & ALLOW_MOUSE) != 0) + && (clicktype != CLICK_RIGHT || mask != 0) // reassigning menu button is not supported + && ((mKeyFilterMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) // reserved for selection + { + setKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); + result = TRUE; + if (!down) + { + // wait for 'up' event before closing + // alternative: set pUpdater + closeFloater(); + } + } + + return result; +} + +//static +void LLSetKeyBindDialog::onCancel(void* user_data) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + self->closeFloater(); +} + +//static +void LLSetKeyBindDialog::onBlank(void* user_data) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + // tmp needs 'no key' button + self->setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); + self->closeFloater(); +} + +//static +void LLSetKeyBindDialog::onDefault(void* user_data) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + if (self->pParent) + { + self->pParent->onDefaultKeyBind(); + self->pParent = NULL; + } + self->closeFloater(); +} + +//static +void LLSetKeyBindDialog::onClickTimeout(void* user_data, MASK mask) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + + // timer will delete itself after timeout + self->pUpdater = NULL; + + self->setKeyBind(CLICK_LEFT, KEY_NONE, mask, self->pCheckBox->getValue().asBoolean()); + self->closeFloater(); +} + +void LLSetKeyBindDialog::setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore) +{ + if (pParent) + { + pParent->onSetKeyBind(click, key, mask, ignore); + pParent = NULL; + } +} + -- cgit v1.2.3 From e211372923bed31e632bc9825913d3d57cdc2d52 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 3 Oct 2019 22:45:29 +0300 Subject: SL-6109 Remade 'ignore' list processing, renamed and reformed keybindings --- indra/newview/llsetkeybinddialog.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'indra/newview/llsetkeybinddialog.cpp') diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index 0ad71cb372..320f1f297d 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -34,6 +34,7 @@ #include "llcheckboxctrl.h" #include "lleventtimer.h" #include "llfocusmgr.h" +#include "llkeyconflict.h" class LLSetKeyBindDialog::Updater : public LLEventTimer { @@ -85,6 +86,7 @@ BOOL LLSetKeyBindDialog::postBuild() getChild("Cancel")->setFocus(TRUE); pCheckBox = getChild("ignore_masks"); + pDesription = getChild("descritption"); gFocusMgr.setKeystrokesOnly(TRUE); @@ -116,14 +118,12 @@ void LLSetKeyBindDialog::draw() LLModalDialog::draw(); } -void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) +void LLSetKeyBindDialog::setParent(LLKeyBindResponderInterface* parent, LLView* frustum_origin, U32 key_mask) { pParent = parent; - setFrustumOrigin(parent); + setFrustumOrigin(frustum_origin); mKeyFilterMask = key_mask; - LLTextBase *text_ctrl = getChild("descritption"); - std::string input; if ((key_mask & ALLOW_MOUSE) != 0) { @@ -137,7 +137,8 @@ void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_ma } input += getString("keyboard"); } - text_ctrl->setTextArg("[INPUT]", input); + pDesription->setText(getString("basic_description")); + pDesription->setTextArg("[INPUT]", input); bool can_ignore_masks = (key_mask & CAN_IGNORE_MASKS) != 0; pCheckBox->setVisible(can_ignore_masks); @@ -185,6 +186,13 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) return FALSE; } + if (LLKeyConflictHandler::isReservedByMenu(key, mask)) + { + pDesription->setText(getString("reserved_by_menu")); + pDesription->setTextArg("[KEYSTR]", LLKeyboard::stringFromAccelerator(mask,key)); + return TRUE; + } + setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); closeFloater(); return TRUE; -- cgit v1.2.3 From 62214b53f09c453dc410465ba6e64a772562e6db Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 28 Oct 2019 18:27:13 +0200 Subject: SL-6109 Fixed conflict resolution issue caused by menu accelerators --- indra/newview/llsetkeybinddialog.cpp | 53 ++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'indra/newview/llsetkeybinddialog.cpp') diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index 320f1f297d..806c70aa03 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -28,11 +28,10 @@ #include "llsetkeybinddialog.h" -//#include "llkeyboard.h" - #include "llbutton.h" #include "llcheckboxctrl.h" #include "lleventtimer.h" +#include "llfloaterreg.h" #include "llfocusmgr.h" #include "llkeyconflict.h" @@ -65,6 +64,8 @@ private: callback_t mCallback; }; +bool LLSetKeyBindDialog::sRecordKeys = false; + LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) : LLModalDialog(key), pParent(NULL), @@ -93,9 +94,17 @@ BOOL LLSetKeyBindDialog::postBuild() return TRUE; } +//virtual +void LLSetKeyBindDialog::onOpen(const LLSD& data) +{ + sRecordKeys = true; + LLModalDialog::onOpen(data); +} + //virtual void LLSetKeyBindDialog::onClose(bool app_quiting) { + sRecordKeys = false; if (pParent) { pParent->onCancelKeyBind(); @@ -145,20 +154,41 @@ void LLSetKeyBindDialog::setParent(LLKeyBindResponderInterface* parent, LLView* pCheckBox->setValue(false); } -BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) +// static +bool LLSetKeyBindDialog::recordKey(KEY key, MASK mask) +{ + if (sRecordKeys) + { + LLSetKeyBindDialog* dialog = LLFloaterReg::getTypedInstance("keybind_dialog", LLSD()); + if (dialog && dialog->getVisible()) + { + return dialog->recordAndHandleKey(key, mask); + } + else + { + LL_WARNS() << "Key recording was set despite no open dialog" << LL_ENDL; + sRecordKeys = false; + } + } + return false; +} + +bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask) { if ((key == 'Q' && mask == MASK_CONTROL) || key == KEY_ESCAPE) { + sRecordKeys = false; closeFloater(); - return TRUE; + return true; } if (key == KEY_DELETE) { setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); + sRecordKeys = false; closeFloater(); - return FALSE; + return false; } // forbidden keys @@ -166,36 +196,37 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) || key == KEY_RETURN || key == KEY_BACKSPACE) { - return FALSE; + return false; } if ((mKeyFilterMask & ALLOW_MASKS) == 0 && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) { // mask by themself are not allowed - return FALSE; + return false; } else if ((mKeyFilterMask & ALLOW_KEYS) == 0) { // basic keys not allowed - return FALSE; + return false; } else if ((mKeyFilterMask & ALLOW_MASK_KEYS) == 0 && mask != 0) { // masked keys not allowed - return FALSE; + return false; } if (LLKeyConflictHandler::isReservedByMenu(key, mask)) { pDesription->setText(getString("reserved_by_menu")); pDesription->setTextArg("[KEYSTR]", LLKeyboard::stringFromAccelerator(mask,key)); - return TRUE; + return true; } setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); + sRecordKeys = false; closeFloater(); - return TRUE; + return true; } BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) -- cgit v1.2.3 From 73a1877ff0abcba46f66ef55440274119427723b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 7 Nov 2019 20:09:25 +0200 Subject: SL-6109 - Edit mode appears to be obsolete and is not used, cleaned up - Improved ability to set defaults - Improved some labels - Made buttons bigger to accomodate languages with longer descriptions - Added ability to assign key for all modes simultaneously --- indra/newview/llsetkeybinddialog.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'indra/newview/llsetkeybinddialog.cpp') diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index 806c70aa03..8d0d71daaf 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -86,7 +86,7 @@ BOOL LLSetKeyBindDialog::postBuild() childSetAction("Cancel", onCancel, this); getChild("Cancel")->setFocus(TRUE); - pCheckBox = getChild("ignore_masks"); + pCheckBox = getChild("apply_all"); pDesription = getChild("descritption"); gFocusMgr.setKeystrokesOnly(TRUE); @@ -148,10 +148,6 @@ void LLSetKeyBindDialog::setParent(LLKeyBindResponderInterface* parent, LLView* } pDesription->setText(getString("basic_description")); pDesription->setTextArg("[INPUT]", input); - - bool can_ignore_masks = (key_mask & CAN_IGNORE_MASKS) != 0; - pCheckBox->setVisible(can_ignore_masks); - pCheckBox->setValue(false); } // static @@ -308,7 +304,7 @@ void LLSetKeyBindDialog::onDefault(void* user_data) LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; if (self->pParent) { - self->pParent->onDefaultKeyBind(); + self->pParent->onDefaultKeyBind(self->pCheckBox->getValue().asBoolean()); self->pParent = NULL; } self->closeFloater(); @@ -326,11 +322,11 @@ void LLSetKeyBindDialog::onClickTimeout(void* user_data, MASK mask) self->closeFloater(); } -void LLSetKeyBindDialog::setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore) +void LLSetKeyBindDialog::setKeyBind(EMouseClickType click, KEY key, MASK mask, bool all_modes) { if (pParent) { - pParent->onSetKeyBind(click, key, mask, ignore); + pParent->onSetKeyBind(click, key, mask, all_modes); pParent = NULL; } } -- cgit v1.2.3 From 0d78aa31e2bd2cf55c83a4447027a94b0939ae26 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 11 Nov 2019 20:38:52 +0200 Subject: SL-6109 Removed LLDrawFrustum and used changes from EEP to prevent merge conflicts --- indra/newview/llsetkeybinddialog.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsetkeybinddialog.cpp') diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index 8d0d71daaf..4eb76c9d89 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -34,6 +34,7 @@ #include "llfloaterreg.h" #include "llfocusmgr.h" #include "llkeyconflict.h" +#include "llviewercontrol.h" class LLSetKeyBindDialog::Updater : public LLEventTimer { @@ -70,8 +71,15 @@ LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) : LLModalDialog(key), pParent(NULL), mKeyFilterMask(DEFAULT_KEY_FILTER), - pUpdater(NULL) + pUpdater(NULL), + mContextConeOpacity(0.f), + mContextConeInAlpha(0.f), + mContextConeOutAlpha(0.f), + mContextConeFadeTime(0.f) { + mContextConeInAlpha = gSavedSettings.getF32("ContextConeInAlpha"); + mContextConeOutAlpha = gSavedSettings.getF32("ContextConeOutAlpha"); + mContextConeFadeTime = gSavedSettings.getF32("ContextConeFadeTime"); } LLSetKeyBindDialog::~LLSetKeyBindDialog() @@ -119,18 +127,23 @@ void LLSetKeyBindDialog::onClose(bool app_quiting) LLModalDialog::onClose(app_quiting); } +void LLSetKeyBindDialog::drawFrustum() +{ + static LLCachedControl max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); + drawConeToOwner(mContextConeOpacity, max_opacity, mFrustumOrigin.get(), mContextConeFadeTime, mContextConeInAlpha, mContextConeOutAlpha); +} + //virtual void LLSetKeyBindDialog::draw() { - LLRect local_rect; - drawFrustum(local_rect, this, (LLView*)getDragHandle(), hasFocus()); + drawFrustum(); LLModalDialog::draw(); } void LLSetKeyBindDialog::setParent(LLKeyBindResponderInterface* parent, LLView* frustum_origin, U32 key_mask) { pParent = parent; - setFrustumOrigin(frustum_origin); + mFrustumOrigin = frustum_origin->getHandle(); mKeyFilterMask = key_mask; std::string input; -- cgit v1.2.3 From 9abac37e42781aaacfc9331627182c2e83f98fd9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 2 Dec 2020 13:48:27 +0200 Subject: SL-14438 Fixed Viewer lost ability to assign Masks as keys --- indra/newview/llsetkeybinddialog.cpp | 41 +++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'indra/newview/llsetkeybinddialog.cpp') diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index 4eb76c9d89..a7f005ec19 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -164,14 +164,14 @@ void LLSetKeyBindDialog::setParent(LLKeyBindResponderInterface* parent, LLView* } // static -bool LLSetKeyBindDialog::recordKey(KEY key, MASK mask) +bool LLSetKeyBindDialog::recordKey(KEY key, MASK mask, BOOL down) { if (sRecordKeys) { LLSetKeyBindDialog* dialog = LLFloaterReg::getTypedInstance("keybind_dialog", LLSD()); if (dialog && dialog->getVisible()) { - return dialog->recordAndHandleKey(key, mask); + return dialog->recordAndHandleKey(key, mask, down); } else { @@ -182,7 +182,7 @@ bool LLSetKeyBindDialog::recordKey(KEY key, MASK mask) return false; } -bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask) +bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask, BOOL down) { if ((key == 'Q' && mask == MASK_CONTROL) || key == KEY_ESCAPE) @@ -208,13 +208,35 @@ bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask) return false; } - if ((mKeyFilterMask & ALLOW_MASKS) == 0 - && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) + if (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT) { - // mask by themself are not allowed - return false; + // Mask keys get special treatment + if (down == TRUE) + { + // Most keys are handled on 'down' event because menu is handled on 'down' + // masks are exceptions to let other keys be handled + return false; + } + if ((mKeyFilterMask & ALLOW_MASKS) == 0) + { + // Mask by themself are not allowed + return false; + } + // Mask up event often generates things like 'shift key + shift mask', filter it out. + if (key == KEY_CONTROL) + { + mask &= ~MASK_CONTROL; + } + if (key == KEY_SHIFT) + { + mask &= ~MASK_SHIFT; + } + if (key == KEY_ALT) + { + mask &= ~MASK_ALT; + } } - else if ((mKeyFilterMask & ALLOW_KEYS) == 0) + if ((mKeyFilterMask & ALLOW_KEYS) == 0) { // basic keys not allowed return false; @@ -233,6 +255,9 @@ bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask) } setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); + // Note/Todo: To warranty zero interference we should also consume + // an 'up' event if we recorded on 'down', not just close floater + // on first recorded combination. sRecordKeys = false; closeFloater(); return true; -- cgit v1.2.3 From c713b953e831172bf161d011dc7eda600eb5b139 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 4 Dec 2020 21:25:34 +0200 Subject: SL-14438 Adjusted behavior of recording mask keys If 'mask+key' got rejected, don record it as 'mask' --- indra/newview/llsetkeybinddialog.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'indra/newview/llsetkeybinddialog.cpp') diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index a7f005ec19..4b36822e9a 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -72,6 +72,7 @@ LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) pParent(NULL), mKeyFilterMask(DEFAULT_KEY_FILTER), pUpdater(NULL), + mLastMaskKey(0), mContextConeOpacity(0.f), mContextConeInAlpha(0.f), mContextConeOutAlpha(0.f), @@ -211,15 +212,22 @@ bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask, BOOL down) if (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT) { // Mask keys get special treatment + if ((mKeyFilterMask & ALLOW_MASKS) == 0) + { + // Masks by themself are not allowed + return false; + } if (down == TRUE) { // Most keys are handled on 'down' event because menu is handled on 'down' // masks are exceptions to let other keys be handled + mLastMaskKey = key; return false; } - if ((mKeyFilterMask & ALLOW_MASKS) == 0) + if (mLastMaskKey != key) { - // Mask by themself are not allowed + // This was mask+key combination that got rejected, don't handle mask's key + // Or user did something like: press shift, press ctrl, release shift return false; } // Mask up event often generates things like 'shift key + shift mask', filter it out. @@ -251,6 +259,7 @@ bool LLSetKeyBindDialog::recordAndHandleKey(KEY key, MASK mask, BOOL down) { pDesription->setText(getString("reserved_by_menu")); pDesription->setTextArg("[KEYSTR]", LLKeyboard::stringFromAccelerator(mask,key)); + mLastMaskKey = 0; return true; } -- cgit v1.2.3