aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2012-06-13 14:51:00 +0300
committerQt by Nokia <qt-info@nokia.com>2012-06-25 03:19:10 +0200
commitfd754674d04625ebf254ce2a96cbe39b3d7652d8 (patch)
tree5aa2f8057c389bad01b9ce24aa345b41b6ca3877
parent2c4595ad02ff35011c24ea71c193d5a9710bec30 (diff)
Fix right aligned cursor position in TextInput with geometry changes
Updating the text layout cannot be omitted with NoWrap because line width needs to be updated even with empty content. Change-Id: Ia9b168d6cfe7680cc1c9e7fa641ce7528d2b6d5e Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
-rw-r--r--src/quick/items/qquicktextinput.cpp2
-rw-r--r--tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml4
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp5
3 files changed, 9 insertions, 2 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 0d05d6f9d7..30512a142b 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1588,7 +1588,7 @@ void QQuickTextInput::geometryChanged(const QRectF &newGeometry,
{
Q_D(QQuickTextInput);
if (!d->inLayout) {
- if (newGeometry.width() != oldGeometry.width() && d->wrapMode != NoWrap)
+ if (newGeometry.width() != oldGeometry.width())
d->updateLayout();
updateCursorRectangle();
}
diff --git a/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
index d14caea619..cf092509b4 100644
--- a/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
@@ -16,7 +16,9 @@ Rectangle {
TextInput {
id: text
objectName: "text"
- anchors.fill: parent
+ anchors.left: parent.left
+ anchors.top: parent.top
+ width: 180
text: top.text
focus: true
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 5044f488ac..a87cbeb5dc 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -1441,6 +1441,11 @@ void tst_qquicktextinput::horizontalAlignment_RightToLeft()
QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignLeft);
platformInputContext.setInputDirection(Qt::RightToLeft);
QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignRight);
+
+ // changing width keeps right aligned cursor on proper position
+ textInput->setText("");
+ textInput->setWidth(500);
+ QVERIFY(textInput->positionToRectangle(0).x() > textInput->width() / 2);
}
void tst_qquicktextinput::verticalAlignment()