text().length() was used to check if a cursor movement
to the right was valid. The problem is that with a mask and
not text set yet (inputMask: "#0:00;*") pressing the right
arrow would not move the cursor.
The input and other functions use the actual d->m_text
since that includes the mask length.
Task-number: QTBUG-30740
Change-Id: Ic225778e5a49d80b754b63d0eb4a438eaa9818e2
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
int cursorPosition = d->m_cursor;
if (cursorPosition == 0)
ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Left : Qt::Key_Right);
- if (!ignore && cursorPosition == text().length())
+ if (!ignore && cursorPosition == d->m_text.length())
ignore = ev->key() == (d->layoutDirection() == Qt::LeftToRight ? Qt::Key_Right : Qt::Key_Left);
}
if (ignore) {
keys << Qt::Key_Home << "12ab";
QTest::newRow("uppercase") << QString("9999 >AA;_") << keys << QString("12 AB") << QString("12__ AB");
}
+ {
+ KeyList keys;
+ // inserting '12ab'
+ keys << Qt::Key_Right << Qt::Key_Right << "1";
+ QTest::newRow("Move in mask") << QString("#0:00;*") << keys << QString(":1") << QString("**:1*");
+ }
}
void tst_qquicktextinput::keypress_inputMask()