]> git.lyx.org Git - features.git/commitdiff
Do not override (Back)Tab in Adv F&R when it is useful
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 18 Jul 2022 10:02:28 +0000 (12:02 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 18 Jul 2022 10:02:28 +0000 (12:02 +0200)
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

index f9016f1465ac5658b31968fe7512902342cf5072..f78700b00a8a59580348ed45ed612ffbb1d3575d 100644 (file)
@@ -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;