From: Urban Wallasch Date: Thu, 24 Jun 2021 15:03:48 +0000 (+0200) Subject: * Improved mouse-over kanji detection in word dic results. X-Git-Tag: v0.1.0~39 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=51bbdb3a359302416ced0566ef8a8eb7f7b2a64f;p=jiten-pai.git * Improved mouse-over kanji detection in word dic results. --- diff --git a/jiten-pai.py b/jiten-pai.py index 2b24961..794829a 100755 --- a/jiten-pai.py +++ b/jiten-pai.py @@ -427,14 +427,15 @@ class zQTextEdit(QTextEdit): self.app.restoreOverrideCursor() def mouseMoveEvent(self, event): - pos = event.pos() - pos.setX(pos.x() - 15) scr = self.verticalScrollBar().value() old_tcur = self.textCursor() - tcur = self.cursorForPosition(pos) + cwidth = QFontMetrics(QFont(cfg['lfont'], cfg['lfont_sz'])).horizontalAdvance('範') + tcur = self.cursorForPosition(QPoint(event.pos().x() - cwidth/2, event.pos().y())) self.setTextCursor(tcur) - tcur.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor); - char = tcur.selectedText() + char = '' + if not (tcur.atBlockStart() and event.pos().x() - self.pos().x() > cwidth): + tcur.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor); + char = tcur.selectedText() self.setTextCursor(old_tcur) self.verticalScrollBar().setValue(scr) if is_kanji(char):