diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-25 11:06:58 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-26 12:59:23 +0200 |
commit | 39286a50c32321981adb82ea47c93b7398b257d8 (patch) | |
tree | bb39438cd2f8498188ebcb36558f813a5deec3de /src/quick/items/qquicktextedit.cpp | |
parent | d324db8839c5a06980384d0b2d4e06125bb5a83d (diff) |
Fix cursor blinking for TextInput and TextEdit
Before commit fb339b21b8a24b835cea7a057c47b7c5ad80dd72 relied on the simple
transparent rectangle node to remain invisible. After that commit we used the
regular rectangle node, which doesn't seem to like toggling the color between
transparent and solid black and therefore the cursor was always visible.
As advised by Gunnar this patch implements a much simpler logic: When the
cursor is supposed to be invisible, we just don't create a scene graph node for
it anymore.
Change-Id: I7b0e173f6d37997559ee0911f37903efdb14847f
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index e8c2199076..aca7150ca2 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -153,8 +153,10 @@ namespace { removeChildNode(cursorNode); delete cursorNode; cursorNode = newNode; - appendChildNode(cursorNode); - cursorNode->setFlag(QSGNode::OwnedByParent); + if (cursorNode) { + appendChildNode(cursorNode); + cursorNode->setFlag(QSGNode::OwnedByParent); + } } QSGRectangleNode *cursorNode; @@ -1903,10 +1905,10 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * } if (d->cursorComponent == 0 && !isReadOnly()) { - QColor color = (!d->cursorVisible || !d->control->cursorOn()) - ? QColor(0, 0, 0, 0) - : d->color; - rootNode->resetCursorNode(d->sceneGraphContext()->createRectangleNode(cursorRectangle(), color)); + QSGRectangleNode* cursor = 0; + if (d->cursorVisible && d->control->cursorOn()) + cursor = d->sceneGraphContext()->createRectangleNode(cursorRectangle(), d->color); + rootNode->resetCursorNode(cursor); } return rootNode; |