Any component. How do I know which Canvas is currently Dragged?

Hi,
I have four canvas on the screen and each filled with different colors. Users can draw with fingers on any of the Canvas. When use "When Any Canvas.Dragged" component, how do I know which component is currently use drawing?

Let's say user is drawing on Canvas1. I want to count how many strokes that use draw on that Canvas1. How do I specify Canvas1 in this block below?

If there's no way to do this, I just use these blocks below to detect. This is currently working, but just want to figure out if there are better ways.

Regards,
Stonez56

Unfortunately 'component' is an identifier that is unrelated to the name you gave to the canvas, so four individual Blocks is the way to go in this case.

Make a list of the canvases on initialise.

Compare the "component" drawn on with the list

Save the drawing strokes to your list against the canvas from the list, which matches.

You can do this with a list.


4 Likes


multi_canvas_draw.aia (2.6 KB)
Sample Run

Here's an example using a dictionary of components and counters.

2 Likes

That's a very neat solution Patryk

@Patryk_F Thanks for the great and elegant solution!

1 Like

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