From 2b24c03e8b83e6397c5cbf7dcd69f77fb4e67e62 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 18 Jul 2022 12:02:28 +0200 Subject: [PATCH] Do not override (Back)Tab in Adv F&R when it is useful In Advanced Find and Replace, Tab can be used to move the focus from Search field to the replace field. This is inconvenient when Tab has another use, like completion. To fix this, check that the function bound to Tab is disabled before switching focus. The same is done for BackTab. Fixes bug #11114. --- src/frontends/qt/FindAndReplace.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/frontends/qt/FindAndReplace.cpp b/src/frontends/qt/FindAndReplace.cpp index f9016f1465..f78700b00a 100644 --- a/src/frontends/qt/FindAndReplace.cpp +++ b/src/frontends/qt/FindAndReplace.cpp @@ -21,6 +21,9 @@ #include "BufferView.h" #include "Cursor.h" #include "FuncRequest.h" +#include "FuncStatus.h" +#include "KeyMap.h" +#include "KeySequence.h" #include "Language.h" #include "LyX.h" #include "lyxfind.h" @@ -113,8 +116,11 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event) } case Qt::Key_Tab: - if (e->modifiers() == Qt::NoModifier) { - if (obj == find_work_area_){ + if (e->modifiers() == Qt::NoModifier && obj == find_work_area_){ + KeySequence seq; + seq.parse("Tab"); + FuncRequest func = theTopLevelKeymap().getBinding(seq); + if (!getStatus(func).enabled()) { LYXERR(Debug::FINDVERBOSE, "Focusing replace WA"); replace_work_area_->setFocus(); LYXERR(Debug::FINDVERBOSE, "Selecting entire replace buffer"); @@ -127,12 +133,17 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event) case Qt::Key_Backtab: if (obj == replace_work_area_) { - LYXERR(Debug::FINDVERBOSE, "Focusing find WA"); - find_work_area_->setFocus(); - LYXERR(Debug::FINDVERBOSE, "Selecting entire find buffer"); - dispatch(FuncRequest(LFUN_BUFFER_BEGIN)); - dispatch(FuncRequest(LFUN_BUFFER_END_SELECT)); - return true; + KeySequence seq; + seq.parse("~S-BackTab"); + FuncRequest func = theTopLevelKeymap().getBinding(seq); + if (!getStatus(func).enabled()) { + LYXERR(Debug::FINDVERBOSE, "Focusing find WA"); + find_work_area_->setFocus(); + LYXERR(Debug::FINDVERBOSE, "Selecting entire find buffer"); + dispatch(FuncRequest(LFUN_BUFFER_BEGIN)); + dispatch(FuncRequest(LFUN_BUFFER_END_SELECT)); + return true; + } } break; -- 2.39.2