From f7b6b96aefc3cd4d65800bdda8d85b264ac524af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:14:27 +0800 Subject: [PATCH] focus --- LunaTranslator/LunaTranslator/gui/showword.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 42fa375c..49335be9 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -171,9 +171,9 @@ class AnkiWindow(QWidget): margin0=True, ) ) - self.fronttext = QPlainTextEdit() - self.backtext = QPlainTextEdit() - self.csstext = QPlainTextEdit() + self.fronttext = QPlainTextEdit1() + self.backtext = QPlainTextEdit1() + self.csstext = QPlainTextEdit1() edittemptab.addTab(self.fronttext, "正面") edittemptab.addTab(self.backtext, "背面") edittemptab.addTab(self.csstext, "样式") @@ -375,14 +375,14 @@ class AnkiWindow(QWidget): self.editpath.setReadOnly(True) self.viewimagelabel = QLabel() self.editpath.textChanged.connect(self.wrappedpixmap) - self.example = QPlainTextEdit() + self.example = QPlainTextEdit1() self.example.hiras = None def __(): self.example.hiras = None self.example.textChanged.connect(__) - self.remarks = QPlainTextEdit() + self.remarks = QPlainTextEdit1() recordbtn1 = statusbutton(icons=["fa.microphone", "fa.stop"], colors=["", ""]) recordbtn1.statuschanged.connect( functools.partial(self.startorendrecord, self.audiopath) @@ -655,6 +655,12 @@ class QLineEdit1(QLineEdit): windows.SetFocus(int(self.winId())) return super().mousePressEvent(a0) +class QPlainTextEdit1(QPlainTextEdit): + def mousePressEvent(self, a0: QMouseEvent) -> None: + # 点击浏览器后,无法重新获取焦点。 + windows.SetFocus(int(self.winId())) + return super().mousePressEvent(a0) + class searchwordW(closeashidewindow): search_word = pyqtSignal(str, bool)