removeChildNode(cursorNode);
delete cursorNode;
cursorNode = newNode;
- appendChildNode(cursorNode);
- cursorNode->setFlag(QSGNode::OwnedByParent);
+ if (cursorNode) {
+ appendChildNode(cursorNode);
+ cursorNode->setFlag(QSGNode::OwnedByParent);
+ }
}
QSGRectangleNode *cursorNode;
}
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;
node = new QQuickTextNode(this);
d->textNode = node;
- if (!d->textLayoutDirty && oldNode != 0) {
- QSGRectangleNode *cursorNode = node->cursorNode();
- if (cursorNode != 0 && !isReadOnly()) {
- cursorNode->setRect(cursorRectangle());
+ const bool showCursor = !isReadOnly() && d->cursorItem == 0 && d->cursorVisible && (d->m_blinkStatus || d->m_blinkPeriod == 0);
- if (!d->cursorVisible || d->cursorItem || (!d->m_blinkStatus && d->m_blinkPeriod > 0)) {
- d->hideCursor();
- } else {
- d->showCursor();
- }
- }
+ if (!d->textLayoutDirty && oldNode != 0) {
+ if (showCursor)
+ node->setCursor(cursorRectangle(), d->color);
+ else
+ node->clearCursor();
} else {
node->setUseNativeRenderer(d->renderType == NativeRendering);
node->deleteContent();
// selection
}
- if (!isReadOnly() && d->cursorItem == 0) {
- node->setCursor(cursorRectangle(), d->color);
- if (!d->cursorVisible || (!d->m_blinkStatus && d->m_blinkPeriod > 0)) {
- d->hideCursor();
- } else {
- d->showCursor();
- }
- }
+ if (showCursor)
+ node->setCursor(cursorRectangle(), d->color);
d->textLayoutDirty = false;
}
}
}
-void QQuickTextInputPrivate::showCursor()
-{
- if (textNode != 0 && textNode->cursorNode() != 0) {
- QSGRectangleNode *cursor = textNode->cursorNode();
- cursor->setColor(color);
- cursor->update();
- }
-}
-
-void QQuickTextInputPrivate::hideCursor()
-{
- if (textNode != 0 && textNode->cursorNode() != 0) {
- QSGRectangleNode *cursor = textNode->cursorNode();
- cursor->setColor(QColor(0, 0, 0, 0));
- cursor->update();
- }
-}
-
QRectF QQuickTextInput::boundingRect() const
{
Q_D(const QQuickTextInput);
appendChildNode(m_cursorNode);
}
+void QQuickTextNode::clearCursor()
+{
+ if (m_cursorNode)
+ removeChildNode(m_cursorNode);
+ delete m_cursorNode;
+ m_cursorNode = 0;
+}
+
void QQuickTextNode::initEngine(const QColor& textColor, const QColor& selectedTextColor, const QColor& selectionColor, const QColor& anchorColor, const QPointF &position)
{
m_engine.reset(new QQuickTextNodeEngine);
int selectionStart = -1, int selectionEnd = -1);
void setCursor(const QRectF &rect, const QColor &color);
+ void clearCursor();
QSGRectangleNode *cursorNode() const { return m_cursorNode; }
QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,