I'm trying to use more than 2 points in MultiPointTouchArea
MultiPointTouchArea {
id: touchArea
anchors.fill: parent
maximumTouchPoints: 5
minimumTouchPoints: 1
touchPoints: [
TouchPoint { id: point1 },
TouchPoint { id: point2 },
TouchPoint { id: point3 },
TouchPoint { id: point4 },
TouchPoint { id: point5 }
]
// Workaround for item.contains(point)
function isInsideItem(item, point) {
var hx = item.x + item.width;
var lx = item.x;
var hy = item.y + item.height;
var ly = item.y;
if (point.x > lx && point.x < hx && point.y > ly && point.y < hy)
return true;
return false;
}
onPressed: {
for (var i = 0; i < repeater.count; i++) {
var item = repeater.itemAt(i)
for (var j = 0; j < touchPoints.length; j++) {
var point = touchPoints[j];
if (isInsideItem(item, point)) {
sbuttons.play(i+1)
item.color = "red";
}
}
}
}
onReleased: {
for (var i = 0; i < repeater.count; i++) {
var item = repeater.itemAt(i)
for (var j = 0; j < touchPoints.length; j++) {
var point = touchPoints[j];
if (isInsideItem(item, point)) {
sbuttons.stop(i+1)
item.color = "white";
}
}
}
}
...
MultiPointTouchArea {
id: touchArea
anchors.fill: parent
maximumTouchPoints: 5
minimumTouchPoints: 1
touchPoints: [
TouchPoint { id: point1 },
TouchPoint { id: point2 },
TouchPoint { id: point3 },
TouchPoint { id: point4 },
TouchPoint { id: point5 }
]
// Workaround for item.contains(point)
function isInsideItem(item, point) {
var hx = item.x + item.width;
var lx = item.x;
var hy = item.y + item.height;
var ly = item.y;
if (point.x > lx && point.x < hx && point.y > ly && point.y < hy)
return true;
return false;
}
onPressed: {
for (var i = 0; i < repeater.count; i++) {
var item = repeater.itemAt(i)
for (var j = 0; j < touchPoints.length; j++) {
var point = touchPoints[j];
if (isInsideItem(item, point)) {
sbuttons.play(i+1)
item.color = "red";
}
}
}
}
onReleased: {
for (var i = 0; i < repeater.count; i++) {
var item = repeater.itemAt(i)
for (var j = 0; j < touchPoints.length; j++) {
var point = touchPoints[j];
if (isInsideItem(item, point)) {
sbuttons.stop(i+1)
item.color = "white";
}
}
}
}
...
To copy to clipboard, switch view to plain text mode
But when I'm using more than 2 fingers, I still have two points in touchPoints array. Third finger just does nothing.
What am I doing wrong?
Bookmarks