VL Multi Touch Skia "Buttons"

I’m trying to detect when each touch point is pressed. In the attached example, with the mouse, the single input works perfectly, and you can see each box change colour when the mouse pointer is within the “RecContainsPoint”.

If I work in the same way with multitouch, as soon as I attach the touchstate output the boxes disappear, because the touch state only becomes active if the screen is being touched, (unlike the mouse state which is constantly on).

As I have 10 point touch frame, my thought is that I need to track 10 points all the time, regardless of if they are active or not, and update their positions when the screen is touched. I was thinking this would also need a dictionary, based on the ID so that when points are added, or taken away they remain in the right order.

Just need a bit of a nudge in the right direction.


VL Multitouch Hit Test.vl (39.1 KB)

One problem I see in your patch is that you enter the ForEach Region with both, your Rectangle Spread and your Touch Spread via Sinks. This may work for one touch but will fail for multitouch. You have to check ALL touchches for each rectangle. a foreach within a foreach.

Also have a look at the “Multitouch” Helppatch. Inside the “MTStack”.

Realized one of my recent forum posts was pretty much the same as this one from a while ago! Have dug back into this and really want to find the solution. Have a few varaitions of trying your soluttion @schlonzo but haven’t quite cracked it yet!

VL Multitouch Hit Test 4.vl (62.7 KB)

I’ve made a version that can be tested without a touch, might make it easier to see a solution.
VL Multitouch Hit Test 5 with random input for testing without touch.vl (84.3 KB)

Finally managed to work it out… Each layer was obscuring the one below, so only one touch point could be seen, used the Keep in the for each loop to only keep the rectangles that contained the points.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.