return;
d->cursorVisible = on;
d->setCursorBlinkPeriod(on ? qApp->styleHints()->cursorFlashTime() : 0);
- QRect r = cursorRectangle();
- if (d->inputMask().isEmpty())
- updateRect(r);
- else
- updateRect();
+ update();
emit cursorVisibleChanged(d->cursorVisible);
}
int c = d->m_cursor;
if (d->m_preeditCursor != -1)
c += d->m_preeditCursor;
- if (d->m_echoMode == NoEcho || !isComponentComplete())
+ if (d->m_echoMode == NoEcho)
c = 0;
QTextLine l = d->m_textLayout.lineForTextPosition(c);
+ if (!l.isValid())
+ return QRect();
return QRect(
qRound(l.cursorToX(c) - d->hscroll),
qRound(l.y() - d->vscroll),
if (pos > d->m_cursor)
pos += d->preeditAreaText().length();
QTextLine l = d->m_textLayout.lineAt(0);
- return QRectF(l.cursorToX(pos) - d->hscroll, 0.0, d->m_cursorWidth, l.height());
+ return l.isValid()
+ ? QRectF(l.cursorToX(pos) - d->hscroll, 0.0, d->m_cursorWidth, l.height())
+ : QRectF();
}
/*!
break;
line = nextLine;
}
- return line.xToCursor(x, position);
+ return line.isValid() ? line.xToCursor(x, position) : 0;
}
void QQuickTextInput::keyPressEvent(QKeyEvent* ev)
q->connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()),
q, SLOT(q_canPasteChanged()));
#endif // QT_NO_CLIPBOARD
- m_textLayout.beginLayout();
- m_textLayout.createLine();
- m_textLayout.endLayout();
imHints &= ~Qt::ImhMultiLine;
oldValidity = hasAcceptableInput(m_text);
void QQuickTextInput::selectionChanged()
{
Q_D(QQuickTextInput);
- updateRect();//TODO: Only update rect in selection
+ d->textLayoutDirty = true; //TODO: Only update rect in selection
+ update();
emit selectedTextChanged();
if (d->lastSelectionStart != d->selectionStart()) {
textNode->cursorNode()->setColor(QColor(0, 0, 0, 0));
}
-void QQuickTextInput::updateRect(const QRect &r)
-{
- Q_D(QQuickTextInput);
- if (!isComponentComplete())
- return;
-
- if (r.isEmpty()) {
- d->textLayoutDirty = true;
- }
-
- update();
-}
-
QRectF QQuickTextInput::boundingRect() const
{
Q_D(const QQuickTextInput);
} else {
m_blinkTimer = 0;
if (m_blinkStatus == 1)
- emit q->updateRect(inputMask().isEmpty() ? q->cursorRectangle() : QRect());
+ q->update();
}
m_blinkPeriod = msec;
}
Q_D(QQuickTextInput);
if (event->timerId() == d->m_blinkTimer) {
d->m_blinkStatus = !d->m_blinkStatus;
- updateRect(inputMask().isEmpty() ? cursorRectangle() : QRect());
+ update();
} else if (event->timerId() == d->m_deleteAllTimer) {
killTimer(d->m_deleteAllTimer);
d->m_deleteAllTimer = 0;
QTRY_COMPARE(&view, qGuiApp->focusWindow());
QQuickTextInput input;
+ input.componentComplete();
QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool)));
QCOMPARE(input.isCursorVisible(), false);
QQuickTextInput input;
input.setText(text);
+ input.componentComplete();
QTextLayout layout(text);
layout.setFont(input.font());
// input panel should stay visible if focus is lost to another text inputor
QSignalSpy inputPanelVisibilitySpy(qApp->inputPanel(), SIGNAL(visibleChanged()));
QQuickTextInput anotherInput;
+ anotherInput.componentComplete();
anotherInput.setParentItem(view.rootObject());
anotherInput.setFocus(true);
QCOMPARE(qApp->inputPanel()->visible(), true);
input.setFocus(true);
input2.setParentItem(view.rootItem());
input.setParentItem(view.rootItem());
+ input.componentComplete();
+ input2.componentComplete();
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);