Make sure that TextInteractionFlags get set.

The first time the function is called,
it could fail to set the flags.

Calling setSelectByKeyboard(true) would not actually
set the text interaction flags (was == on).

The test didn't detect it because it called setReadOnly
before setSelectByKeyboard.

Change-Id: Ia54cc782b6ad5a74f1d7029c92fa230116d034b0
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
This commit is contained in:
Frederik Gladhorn 2013-03-19 15:04:44 +01:00 committed by The Qt Project
parent d6625ac911
commit 7148a79775
2 changed files with 3 additions and 3 deletions

View File

@ -1265,8 +1265,8 @@ void QQuickTextEdit::setSelectByKeyboard(bool on)
{
Q_D(QQuickTextEdit);
bool was = selectByKeyboard();
d->selectByKeyboardSet = true;
if (was != on) {
if (!d->selectByKeyboardSet || was != on) {
d->selectByKeyboardSet = true;
d->selectByKeyboard = on;
if (on)
d->control->setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByKeyboard);

View File

@ -2171,8 +2171,8 @@ void tst_qquicktextedit::keyboardSelection()
QVERIFY(edit);
edit->setText(text);
edit->setReadOnly(readOnly);
edit->setSelectByKeyboard(selectByKeyboard);
edit->setReadOnly(readOnly);
edit->setCursorPosition(cursorPosition);
QQuickWindow window;