From ceb7edd5aae31bc53101ac6e1d57bfea92cde471 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Thu, 19 Dec 2024 10:56:55 -0500 Subject: [PATCH] Widgets: Prevent Chinese input method to block edit input area --- spyder/widgets/mixins.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spyder/widgets/mixins.py b/spyder/widgets/mixins.py index 5e32af56a93..e9c57232e0c 100644 --- a/spyder/widgets/mixins.py +++ b/spyder/widgets/mixins.py @@ -1539,6 +1539,28 @@ def mouseDoubleClickEvent(self, event): elif isinstance(self, QTextEdit): QTextEdit.mouseDoubleClickEvent(self, event) + def inputMethodQuery(self, query): + """ + Prevent Chinese input method to block edit input area. + + Notes + ----- + This was suggested by a user in spyder-ide/spyder#23313. So, it's not + tested by us. + """ + if query == Qt.ImInputItemClipRectangle: + cursor_rect = self.cursorRect() + margins = self.viewportMargins() + cursor_rect.moveTopLeft( + cursor_rect.topLeft() + QPoint(margins.left(), margins.top()) + ) + return cursor_rect + + if isinstance(self, QPlainTextEdit): + QPlainTextEdit.inputMethodQuery(self, query) + elif isinstance(self, QTextEdit): + QTextEdit.inputMethodQuery(self, query) + class TracebackLinksMixin(object): """Mixin to make file names in tracebacks and anchors clickable."""