diff options
author | Tang Haixiang <tanghaixiang@uniontech.com> | 2021-10-27 18:59:33 +0800 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-05 16:29:11 +0000 |
commit | 8aae49019d7386c1abd6cd32f7ccb68c264c0288 (patch) | |
tree | 22d4580d294155ea1432b427d998f8be6ce85d76 /src/gui/text | |
parent | ff92c4c3d817fd2b1e2de05523f8f4ceede4ac58 (diff) |
QTextDocumentLayout: Account for topMargin when hit-testing
When TopMargin is set in TextBlock and the mouse click position is
between Margin (the mouse is not on the textrect), the cursor will
usually jump to the end. So topMargin should be considered when
hitTest() calculates coordinates.
Fixes: QTBUG-91774
Pick-to: 6.4 6.3 6.2
Change-Id: I231377263855b9cd7152684203fc4ed2e9299bb9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tang Haixiang <tanghaixiang@uniontech.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index db3738ba97..714632ba58 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -794,7 +794,7 @@ QTextDocumentLayoutPrivate::hitTest(const QTextBlock &bl, const QFixedPoint &poi textrect.translate(tl->position()); qCDebug(lcHit) << " checking block" << bl.position() << "point=" << point.toPointF() << " tlrect" << textrect; *position = bl.position(); - if (point.y.toReal() < textrect.top()) { + if (point.y.toReal() < textrect.top() - bl.blockFormat().topMargin()) { qCDebug(lcHit) << " before pos=" << *position; return PointBefore; } else if (point.y.toReal() > textrect.bottom()) { |