From 0425562e14e41b62dc7631c7c02768b8294454d0 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 11 Dec 2019 16:38:14 +0100 Subject: ComboBox: add selectTextByMouse property Allows configuring the selectByMouse property of the underlying TextField for editable combo boxes. Named selectTextByMouse instead of selectByMouse to avoid confusion with selection of the items themselves. [ChangeLog][Controls][ComboBox] Added selectTextByMouse property. Change-Id: I852e4cd44ebe6b2a1ed2535513ea2fc35cbe0a32 Fixes: QTBUG-71406 Reviewed-by: Shawn Rutledge --- tests/auto/controls/data/tst_combobox.qml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 2cf71f73..0f1f0bdc 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -1853,4 +1853,20 @@ TestCase { closedSpy.wait() compare(closedSpy.count, 1) } + + function test_comboBoxSelectTextByMouse() { + let control = createTemporaryObject(comboBox, testCase, + { editable: true, selectTextByMouse: true, model: [ "Some text" ], width: parent.width }) + verify(control) + waitForRendering(control) + control.forceActiveFocus() + + // Position the text cursor at the beginning of the text. + mouseClick(control, control.leftPadding, control.height / 2) + // Select all of the text. + mousePress(control, control.leftPadding, control.height / 2) + mouseMove(control, control.leftPadding + control.contentItem.width, control.height / 2) + mouseRelease(control, control.leftPadding + control.contentItem.width, control.height / 2) + compare(control.contentItem.selectedText, "Some text") + } } -- cgit v1.2.3