From e661fa1057641092428b5cb2db74b2f3a9496331 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 29 Apr 2015 12:47:38 +0200 Subject: QQuickButton: Add canceled signal We now support the following pattern: 1. Press the mouse button => emit pressed 2. Move the mouse cursor outside the button => pressed = false 3. Release the mouse button => emit canceled Note that getting the mouse grabbed away by another item, at any stage, will also emit the canceled signal. Change-Id: I97e485327370ea47943dfef75553000cee449a01 Reviewed-by: J-P Nurmi --- tests/auto/controls/data/tst_button.qml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml index c721518d..f4ada30c 100644 --- a/tests/auto/controls/data/tst_button.qml +++ b/tests/auto/controls/data/tst_button.qml @@ -60,6 +60,11 @@ TestCase { signalName: "released" } + SignalSpy { + id: canceledSpy + signalName: "canceled" + } + SignalSpy { id: clickedSpy signalName: "clicked" @@ -112,21 +117,25 @@ TestCase { pressedChangedSpy.target = control releasedSpy.target = control + canceledSpy.target = control clickedSpy.target = control verify(pressedChangedSpy.valid) verify(releasedSpy.valid) + verify(canceledSpy.valid) verify(clickedSpy.valid) // check mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(pressedChangedSpy.count, 1) compare(releasedSpy.count, 0) + compare(canceledSpy.count, 0) compare(clickedSpy.count, 0) compare(control.pressed, true) mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(pressedChangedSpy.count, 2) compare(releasedSpy.count, 1) + compare(canceledSpy.count, 0) compare(clickedSpy.count, 1) compare(control.pressed, false) @@ -134,12 +143,14 @@ TestCase { mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(pressedChangedSpy.count, 3) compare(releasedSpy.count, 1) + compare(canceledSpy.count, 0) compare(clickedSpy.count, 1) compare(control.pressed, true) mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(pressedChangedSpy.count, 4) compare(releasedSpy.count, 2) + compare(canceledSpy.count, 0) compare(clickedSpy.count, 2) compare(control.pressed, false) @@ -147,6 +158,7 @@ TestCase { mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(pressedChangedSpy.count, 5) compare(releasedSpy.count, 2) + compare(canceledSpy.count, 0) compare(clickedSpy.count, 2) compare(control.pressed, true) @@ -155,20 +167,23 @@ TestCase { mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftButton) compare(pressedChangedSpy.count, 6) - compare(releasedSpy.count, 3) + compare(releasedSpy.count, 2) + compare(canceledSpy.count, 1) compare(clickedSpy.count, 2) compare(control.pressed, false) // right button mousePress(control, control.width / 2, control.height / 2, Qt.RightButton) compare(pressedChangedSpy.count, 6) - compare(releasedSpy.count, 3) + compare(releasedSpy.count, 2) + compare(canceledSpy.count, 1) compare(clickedSpy.count, 2) compare(control.pressed, false) mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton) compare(pressedChangedSpy.count, 6) - compare(releasedSpy.count, 3) + compare(releasedSpy.count, 2) + compare(canceledSpy.count, 1) compare(clickedSpy.count, 2) compare(control.pressed, false) -- cgit v1.2.3