diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-09-19 11:20:13 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-09-19 11:43:12 (GMT) |
commit | c750afe0e0f043389d30850070889946e4c6e8af (patch) | |
tree | b4e43b5ba25974ff80d1c9f4e58b5598d6039f9f /src/gui/text | |
parent | 67a1b5e50c1cc90e9c03d9f4cadc9912f6880e15 (diff) | |
download | Qt-c750afe0e0f043389d30850070889946e4c6e8af.zip Qt-c750afe0e0f043389d30850070889946e4c6e8af.tar.gz Qt-c750afe0e0f043389d30850070889946e4c6e8af.tar.bz2 |
Make sure cursor position doesn't exceed line end
If we have trailing spaces at the end of a line, cursor will disappear
because the position we returned exceeds line end, thus the widget
border. By limiting it within line.width we can make sure it always
visible, which is more consistent to the behavior in common platforms.
Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index d0c1a0e..a2662c4 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2612,6 +2612,9 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const x += eng->offsetInLigature(si, pos, end, glyph_pos); } + if (x > line.width) + x = line.width; + *cursorPos = pos + si->position; return x.toReal(); } |