Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
QQuickLineControl more robust on input method & selection state
Input method event having replacement information out of bounds
left the controller in selection state when it shouldn't be.
Also now more liberal on accepted events. We cannot detect if input
method is confused for replacement inside boundaries, but going beyond
the end is more likely to be meant to replace until the end than to
leave previous text in addition to the new one.

Change-Id: I485009ac682c11876b39f7e22d7dfb91a6d162fe
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
  • Loading branch information
Pekka Vuorela authored and Qt by Nokia committed Dec 20, 2011
1 parent b899758 commit 0332e60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/quick/items/qquicktextinput.cpp
Expand Up @@ -2570,6 +2570,7 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
if (event->replacementLength()) {
m_selstart = m_cursor;
m_selend = m_selstart + event->replacementLength();
m_selend = qMin(m_selend, m_text.length());
removeSelectedText();
}
if (!event->commitString().isEmpty()) {
Expand Down
8 changes: 8 additions & 0 deletions tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
Expand Up @@ -1659,6 +1659,14 @@ void tst_qquicktextinput::inputMethods()
QCOMPARE(input->text(), QString(""));
input->setValidator(0);
delete validator;

// input should reset selection even if replacement parameters are out of bounds
input->setText("text");
input->setCursorPosition(0);
input->moveCursorSelection(input->text().length());
event.setCommitString("replacement", -input->text().length(), input->text().length());
QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &event);
QCOMPARE(input->selectionStart(), input->selectionEnd());
}

/*
Expand Down

0 comments on commit 0332e60

Please sign in to comment.