if (oldFont != d->font) {
d->updateLayout();
updateCursorRectangle();
+ qApp->inputPanel()->update(Qt::ImCursorRectangle | Qt::ImFont);
}
emit fontChanged(d->sourceFont);
}
d->updateHorizontalScroll();
d->updateVerticalScroll();
update();
- updateMicroFocus();
emit cursorRectangleChanged();
if (d->cursorItem) {
QRectF r = cursorRectangle();
}
emit q->selectionChanged();
emitCursorPositionChanged();
+ qApp->inputPanel()->update(Qt::ImCursorRectangle | Qt::ImAnchorPosition
+ | Qt::ImCursorPosition | Qt::ImCurrentSelection);
}
/*!
emit q->selectionChanged();
}
emitCursorPositionChanged();
+ q->updateMicroFocus();
}
/*!
m_textLayout.setAdditionalFormats(formats);
updateDisplayText(/*force*/ true);
- if (cursorPositionChanged)
+ if (cursorPositionChanged) {
emitCursorPositionChanged();
- else if (m_preeditCursor != oldPreeditCursor)
+ } else if (m_preeditCursor != oldPreeditCursor) {
q->updateCursorRectangle();
+ qApp->inputPanel()->update(Qt::ImCursorRectangle);
+ }
bool tentativeCommitChanged = m_tentativeCommit != event->tentativeCommitString();
if (isGettingInput || tentativeCommitChanged)
finishChange(priorState);
- if (selectionChange)
+ if (selectionChange) {
emit q->selectionChanged();
+ qApp->inputPanel()->update(Qt::ImCursorRectangle | Qt::ImAnchorPosition
+ | Qt::ImCursorPosition | Qt::ImCurrentSelection);
+ }
}
/*!
Q_Q(QQuickTextInput);
Q_UNUSED(update)
+ bool notifyInputPanel = m_textDirty || m_selDirty;
if (m_textDirty) {
// do validation
m_selDirty = false;
emit q->selectionChanged();
}
+
+ notifyInputPanel |= (m_cursor == m_lastCursorPos);
+ if (notifyInputPanel)
+ q->updateMicroFocus();
emitCursorPositionChanged();
return true;
void preeditCursorRectangle();
void inputContextMouseHandler();
void inputMethodComposing();
+ void inputPanelUpdate();
void cursorRectangleSize();
void getText_data();
QCOMPARE(spy.count(), 2);
}
+void tst_qquicktextinput::inputPanelUpdate()
+{
+ PlatformInputContext platformInputContext;
+ QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
+ inputPanelPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("inputContext.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ // text change even without cursor position change needs to trigger update
+ input->setText("test");
+ platformInputContext.clear();
+ input->setText("xxxx");
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method event replacing text
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y", -1, 1);
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method changing selection
+ platformInputContext.clear();
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
+ QInputMethodEvent inputMethodEvent("", attributes);
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // programmatical selections trigger update
+ platformInputContext.clear();
+ input->selectAll();
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // font changes
+ platformInputContext.clear();
+ QFont font = input->font();
+ font.setBold(!font.bold());
+ input->setFont(font);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // normal input
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y");
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // changing cursor position
+ platformInputContext.clear();
+ input->setCursorPosition(0);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+}
+
void tst_qquicktextinput::cursorRectangleSize()
{
QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));