From a1a4abe377045afee3b49639fd1e072a7cbd8e19 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 9 Dec 2011 16:30:46 +1000 Subject: [PATCH] Size TextInput cursor correctly. Use the cursorRectangle property to size and position the TextNode's cursor rather than recalculating the rectangle in an incompatible way. Task-number: QTBUG-22386 Change-Id: I8ee02b590796b0304683b9b246aba1e59c1fd6a5 Reviewed-by: Michael Brasser --- src/quick/items/qquicktextinput.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index e9caaf2..b389329 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1296,13 +1296,7 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData if (!d->textLayoutDirty) { QSGSimpleRectNode *cursorNode = node->cursorNode(); if (cursorNode != 0 && !isReadOnly()) { - QFontMetrics fm = QFontMetrics(d->font); - // the y offset is there to keep the baseline constant in case we have script changes in the text. - QPoint offset(-d->hscroll, fm.ascent() - d->control->ascent()); - offset.rx() += d->control->cursorToX(); - - QRect br(boundingRect().toRect()); - cursorNode->setRect(QRectF(offset, QSizeF(d->control->cursorWidth(), br.height()))); + cursorNode->setRect(cursorRectangle()); if (!d->cursorVisible || (!d->control->cursorBlinkStatus() && d->control->cursorBlinkPeriod() > 0)) { @@ -1336,8 +1330,7 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData } if (!isReadOnly() && d->cursorItem == 0) { - offset.rx() += d->control->cursorToX(); - node->setCursor(QRectF(offset, QSizeF(d->control->cursorWidth(), br.height())), d->color); + node->setCursor(cursorRectangle(), d->color); if (!d->cursorVisible || (!d->control->cursorBlinkStatus() && d->control->cursorBlinkPeriod() > 0)) { d->hideCursor(); -- 2.7.4