This commit is contained in:
Kovid Goyal 2024-01-11 17:02:30 +05:30
commit 63030d807e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -613,6 +613,20 @@ class HTMLDisplay(QTextBrowser):
else: else:
return QTextBrowser.loadResource(self, rtype, qurl) return QTextBrowser.loadResource(self, rtype, qurl)
def anchorAt(self, pos):
# Anchors in a document can be "focused" with the tab key.
# Unfortunately, the focus point that Qt provides when using the context
# menu key can be 1 pixel out of the anchor's focus rectangle. We
# correct for that here by checking if there is an anchor under the
# point, moving the point a pixel one direction then the other if there
# isn't. This process also slightly dejitters the mouse FWIW.
url = super().anchorAt(pos)
if not url:
url = super().anchorAt(QPoint(pos.x()-1, pos.y()-1))
if not url:
url = super().anchorAt(QPoint(pos.x()+1, pos.y()+1))
return url
class ScrollingTabWidget(QTabWidget): class ScrollingTabWidget(QTabWidget):