diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-10-28 18:27:13 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-06-23 14:50:03 +0300 |
commit | 62214b53f09c453dc410465ba6e64a772562e6db (patch) | |
tree | b3f0f8797c7efa3c1f7da0c436dde685e0d9290c /indra/newview | |
parent | 6597c7696783ce56f89b34a4b6440363635be6a6 (diff) |
SL-6109 Fixed conflict resolution issue caused by menu accelerators
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llkeyconflict.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llsetkeybinddialog.cpp | 53 | ||||
-rw-r--r-- | indra/newview/llsetkeybinddialog.h | 9 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 9 |
4 files changed, 68 insertions, 15 deletions
diff --git a/indra/newview/llkeyconflict.cpp b/indra/newview/llkeyconflict.cpp index 71ba0d37b3..fcf1a7953c 100644 --- a/indra/newview/llkeyconflict.cpp +++ b/indra/newview/llkeyconflict.cpp @@ -174,17 +174,23 @@ bool LLKeyConflictHandler::canAssignControl(const std::string &control_name) // static bool LLKeyConflictHandler::isReservedByMenu(const KEY &key, const MASK &mask) { - return gMenuBarView->hasAccelerator(key, mask) || gLoginMenuBarView->hasAccelerator(key, mask); + if (key == KEY_NONE) + { + return false; + } + return (gMenuBarView && gMenuBarView->hasAccelerator(key, mask)) + || (gLoginMenuBarView && gLoginMenuBarView->hasAccelerator(key, mask)); } // static bool LLKeyConflictHandler::isReservedByMenu(const LLKeyData &data) { - if (data.mMouse != CLICK_NONE) + if (data.mMouse != CLICK_NONE || data.mKey == KEY_NONE) { return false; } - return gMenuBarView->hasAccelerator(data.mKey, data.mMask) || gLoginMenuBarView->hasAccelerator(data.mKey, data.mMask); + return (gMenuBarView && gMenuBarView->hasAccelerator(data.mKey, data.mMask)) + || (gLoginMenuBarView && gLoginMenuBarView->hasAccelerator(data.mKey, data.mMask)); } bool LLKeyConflictHandler::registerControl(const std::string &control_name, U32 index, EMouseClickType mouse, KEY key, MASK mask, bool ignore_mask) 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), @@ -94,8 +95,16 @@ BOOL LLSetKeyBindDialog::postBuild() } //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<LLSetKeyBindDialog>("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) diff --git a/indra/newview/llsetkeybinddialog.h b/indra/newview/llsetkeybinddialog.h index 8faa2cc363..16a2d768e4 100644 --- a/indra/newview/llsetkeybinddialog.h +++ b/indra/newview/llsetkeybinddialog.h @@ -62,12 +62,16 @@ public: ~LLSetKeyBindDialog(); /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& data); /*virtual*/ void onClose(bool app_quiting); /*virtual*/ void draw(); void setParent(LLKeyBindResponderInterface* parent, LLView* frustum_origin, U32 key_mask = DEFAULT_KEY_FILTER); - BOOL handleKeyHere(KEY key, MASK mask); + // Wrapper around recordAndHandleKey + // It does not record, it handles, but handleKey function is already in use + static bool recordKey(KEY key, MASK mask); + BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); static void onCancel(void* user_data); static void onBlank(void* user_data); @@ -77,6 +81,7 @@ public: class Updater; private: + bool recordAndHandleKey(KEY key, MASK mask); void setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore); LLKeyBindResponderInterface *pParent; LLCheckBoxCtrl *pCheckBox; @@ -84,6 +89,8 @@ private: U32 mKeyFilterMask; Updater *pUpdater; + + static bool sRecordKeys; // for convinience and not to check instance each time }; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 091fc720c1..a6bc3373e2 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -45,6 +45,7 @@ #include "llmeshrepository.h" #include "llnotificationhandler.h" #include "llpanellogin.h" +#include "llsetkeybinddialog.h" #include "llviewerinput.h" #include "llviewermenu.h" @@ -2730,6 +2731,14 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // hide tooltips on keypress LLToolTipMgr::instance().blockToolTips(); + // let menus handle navigation keys for navigation + if (LLSetKeyBindDialog::recordKey(key, mask)) + { + LL_DEBUGS() << "Key handled by LLSetKeyBindDialog" << LL_ENDL; + LLViewerEventRecorder::instance().logKeyEvent(key,mask); + return TRUE; + } + LLFocusableElement* keyboard_focus = gFocusMgr.getKeyboardFocus(); if (keyboard_focus |