From accae5e0746e2bf3e1d1ebba80d57195cf4a0f87 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 16 Aug 2020 15:10:02 +0200 Subject: [PATCH] Also capture the return key for the replace box --- nw/gui/doceditor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index f41e67a8..737758bf 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -649,7 +649,7 @@ class GuiDocEditor(QTextEdit): """ isReturn = keyEvent.key() == Qt.Key_Return isReturn |= keyEvent.key() == Qt.Key_Enter - if isReturn and self.docSearch.searchBox.hasFocus(): + if isReturn and self.docSearch.anyFocus(): return elif keyEvent == QKeySequence.Redo: self.docAction(nwDocAction.REDO) @@ -1425,7 +1425,7 @@ class GuiDocEditSearch(QFrame): self.replaceBox = QLineEdit(self) self.replaceBox.setFont(boxFont) self.replaceBox.setPlaceholderText("Replace") - self.replaceBox.returnPressed.connect(self._doSearch) + self.replaceBox.returnPressed.connect(self._doReplace) self.searchOpt = QToolBar(self) self.searchOpt.setToolButtonStyle(Qt.ToolButtonIconOnly) @@ -1591,6 +1591,11 @@ class GuiDocEditSearch(QFrame): return True return False + def anyFocus(self): + """Returns true if any of the input boxes have focus. + """ + return self.searchBox.hasFocus() | self.replaceBox.hasFocus() + ## # Get and Set Functions ##