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

commit4664efe1345e1766f1c4a8ae7e168c8062e3d576 authorMarius Gripsgard <marius@ubports.com> dateFri 9 Mar 2018, 20:48 (9 years ago) parentf5b6600
1 file changed+8−2
qml/Stage/Stage.qml+8−2
qml/Stage/Stage.qml+8−2
@@ -1885,11 +1885,12 @@ FocusScope {
18851885
18861886 property int scrollAreaWidth: width / 3
18871887 property bool progressiveScrollingEnabled: false
1888+ property bool wasTouchPress: false
18881889
18891890 onMouseXChanged: {
18901891 mouse.accepted = false
18911892
1892− if (hoverMouseArea.pressed) {
1893+ if (hoverMouseArea.pressed || wasTouchPress) {
18931894 return;
18941895 }
18951896
@@ -1925,7 +1926,12 @@ FocusScope {
19251926 }
19261927 }
19271928
1928− onPressed: mouse.accepted = false
1929+ onPressed: {
1930+ mouse.accepted = false;
1931+ wasTouchPress = mouse.source === Qt.MouseEventSynthesizedByQt;
1932+ }
1933+
1934+ onExited: wasTouchPress = false;
19291935 }
19301936
19311937 FloatingFlickable {