on xenial help sign in
[Stage/Spread] Detect mouse or touch events in newer qt versions (#33)

* [Stage/Spread] Detect mouse or touch events in newer qt versions With newer versions of qt a touch event will no longer set "pressed" to true, this is what the spread has been relying on to detect mouse or touch events. This adds detection if it's a mouse or touch event in never versions of qt. This fixes: https://github.com/ubports/ubuntu-touch/issues/487 and https://github.com/ubports/ubuntu-touch/issues/430 * Clean code and use a better namve for var

commit035c3fefdb716358810cb2528757ac2cd0d3eef2 authorMarius Gripsgard <marius@ubports.com> dateFri 9 Mar 2018, 20:48 (9 years ago) parent978e966
1 file changed+8−2
qml/Stage/Stage.qml+8−2
qml/Stage/Stage.qml+8−2
@@ -1726,11 +1726,12 @@ FocusScope {
17261726
17271727 property int scrollAreaWidth: width / 3
17281728 property bool progressiveScrollingEnabled: false
1729+ property bool wasTouchPress: false
17291730
17301731 onMouseXChanged: {
17311732 mouse.accepted = false
17321733
1733− if (hoverMouseArea.pressed) {
1734+ if (hoverMouseArea.pressed || wasTouchPress) {
17341735 return;
17351736 }
17361737
@@ -1766,7 +1767,12 @@ FocusScope {
17661767 }
17671768 }
17681769
1769− onPressed: mouse.accepted = false
1770+ onPressed: {
1771+ mouse.accepted = false;
1772+ wasTouchPress = mouse.source === Qt.MouseEventSynthesizedByQt;
1773+ }
1774+
1775+ onExited: wasTouchPress = false;
17701776 }
17711777
17721778 FloatingFlickable {