@Zelta said:
it works. test it.
Not really. Like I said, when I add a polygon it's not working anymore, because a polygon can contain multiple indices.
For example:

When I print the shape_idx and click on the different polygons I get this results:
Click on rect with ...
"1" -> 0
"2" -> 1
"3" -> 2
"4" -> 3
So far no problem, I could easily increment the index to get the right value, but now the problem:
Click on polygon with ...
"5" -> 4
"5" -> 5
I get two different indices, because its splitted in two parts.