Cloning an image as button

Hi there,

I’m trying to clone a set of images as clickable buttons.
When I click on any clone I need to detect in the “on click” block witch button image is clicked.

The idea is that inside the click block I call a function where I do somethings with a ID. Every clone should have an ID that I want to relate to a database record. This way I then can get some info about the clicked button to do things according it’s database info. For example I have an unique text in database record for every button. That text is send to a function after click.

I now have these blocks where I’m able to clone an image that is invisible for origin, and after the clone it pops up. All works but now the dynamic click event.

The way to do click detection for cloned components is to use the find first occurrence of item block to determine where the button/image is that was clicked. So for example, if I have two buttons in a row and I clone that row a bunch of times, if I use the find first occurrence block and it returns 8, then I know that the second button in the fourth row was clicked because my buttons are arranged like this:

1 2
3 4
5 6
7 8

So I can divide the value by 2 to get the row number and I might have to a little creative mathematically to get whether it’s the left or right button. I can also access the button’s properties without that by just using the green component block. Here’s an example. Typically, I would use the list all button in screen or in container but in this screenshot I’m using a loop through all of the containers in a layout (beta version).

image