From 83cb2069ead120e7777a13ef6b7c0a0b14052685 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sun, 28 Feb 2016 22:43:42 +0100 Subject: QQuickText{Edit,Input}: Reset selection when becoming readOnly. When read only, controls may not be edited or altered, and indeed, a read-only control cannot acquire a selection (as it cannot be interacted with). Leaving an existing selection breaks that implication, so clear it when becoming read-only. [ChangeLog][QtQuick][TextEdit/TextInput] If a control has a selection, it is now cleared when becoming read-only. Task-number: QTBUG-51115 Change-Id: Ife43b97ee3d6b780f09a938868c3ccb2f1b6e6e7 Reviewed-by: Simon Hausmann --- tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp') diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index abb2c5b773..3b4e57b2a8 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -221,6 +221,8 @@ private slots: void ensureVisible(); void padding(); + void QTBUG_51115_readOnlyResetsSelection(); + private: void simulateKey(QWindow *, int key); @@ -6697,6 +6699,17 @@ void tst_qquicktextinput::padding() delete root; } +void tst_qquicktextinput::QTBUG_51115_readOnlyResetsSelection() +{ + QQuickView view; + view.setSource(testFileUrl("qtbug51115.qml")); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QQuickTextInput *obj = qobject_cast(view.rootObject()); + + QCOMPARE(obj->selectedText(), QString()); +} + QTEST_MAIN(tst_qquicktextinput) #include "tst_qquicktextinput.moc" -- cgit v1.2.3