diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2014-10-14 10:44:47 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2014-10-30 10:32:53 +0100 |
commit | 02de9d7b6c851d7021dbb901d97c3f91209b1ea9 (patch) | |
tree | d143dc6a40d98a7482d965e40a49c73813dd18ea /src/quick/items/qquicktextcontrol.cpp | |
parent | cf959b4b4ea3d2dfd5243022fea393fadfd95b0d (diff) |
text input: always let cursor rect have a width == 1
Instead of using a cursor width of null when a cursor
delegate is set, we should to use a value of 1.
Otherwise the rect we e.g return from cursorRect() will
be invalid. An alternative would be to use the width of
the delegate, but that was found to be controversial.
On iOS we saw a bug with this when telling iOS to position
text spelling popups underneath the cursor. Since the
cursor rect we got was invalid (zero-width), no popup
would show.
Change-Id: Ice51b9a1bd33f331183e3acec61b7d9c0f5163cd
Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
Diffstat (limited to 'src/quick/items/qquicktextcontrol.cpp')
-rw-r--r-- | src/quick/items/qquicktextcontrol.cpp | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 2585caefb5..0ad21ccff3 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -965,7 +965,6 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const const QTextBlock block = doc->findBlock(position); if (!block.isValid()) return QRectF(); - const QAbstractTextDocumentLayout *docLayout = doc->documentLayout(); const QTextLayout *layout = block.layout(); const QPointF layoutPos = q->blockBoundingRect(block).topLeft(); int relativePos = position - block.position(); @@ -980,24 +979,14 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const #endif QTextLine line = layout->lineForTextPosition(relativePos); - int cursorWidth; - { - bool ok = false; -#ifndef QT_NO_PROPERTIES - cursorWidth = docLayout->property("cursorWidth").toInt(&ok); -#endif - if (!ok) - cursorWidth = 1; - } - QRectF r; if (line.isValid()) { qreal x = line.cursorToX(relativePos); qreal w = 0; - r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), cursorWidth + w, line.height()); + r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), textCursorWidth + w, line.height()); } else { - r = QRectF(layoutPos.x(), layoutPos.y(), cursorWidth, 10); // #### correct height + r = QRectF(layoutPos.x(), layoutPos.y(), textCursorWidth, 10); // #### correct height } return r; @@ -1510,19 +1499,6 @@ QString QQuickTextControl::anchorAt(const QPointF &pos) const return d->doc->documentLayout()->anchorAt(pos); } -void QQuickTextControl::setCursorWidth(int width) -{ - Q_D(QQuickTextControl); -#ifdef QT_NO_PROPERTIES - Q_UNUSED(width); -#else - if (width == -1) - width = textCursorWidth; - d->doc->documentLayout()->setProperty("cursorWidth", width); -#endif - d->repaintCursor(); -} - void QQuickTextControl::setAcceptRichText(bool accept) { Q_D(QQuickTextControl); |