From c6091ed44ed1cf2b5b18c3abb703a0707ef6e22c Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 18 Nov 2016 12:00:49 -0800 Subject: [PATCH] Fix mobile polygon draw --- src/FlightMap/FlightMap.qml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index 2d3b7f2df..96018f1ad 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -349,8 +349,17 @@ Map { // Add first coordinate polygonPath.push(clickCoordinate) } else { - // Update finalized coordinate - polygonPath[polygonDrawerPolygon.path.length - 1] = clickCoordinate + // Add subsequent coordinate + if (ScreenTools.isMobile) { + // Since mobile has no mouse, the onPositionChangedHandler will not fire. We have to add the coordinate + // here instead. + polygonDrawer.justClicked = false + polygonPath.push(clickCoordinate) + } else { + // The onPositionChanged handler for mouse movement will have already added the coordinate to the array. + // Just update it to the final position + polygonPath[polygonDrawerPolygon.path.length - 1] = clickCoordinate + } } polygonDrawerPolygonSet.path = polygonPath polygonDrawerPolygon.path = polygonPath @@ -360,10 +369,15 @@ Map { } onPositionChanged: { + if (ScreenTools.isMobile) { + // We don't track mouse drag on mobile + return + } if (polygonDrawerPolygon.path.length) { var dragCoordinate = _map.toCoordinate(Qt.point(mouse.x, mouse.y)) var polygonPath = polygonDrawerPolygon.path if (polygonDrawer.justClicked){ + // Add new drag coordinate polygonPath.push(dragCoordinate) polygonDrawer.justClicked = false } -- 2.22.0