With a for loop I create 10 different Surfaces. By clicking on one of them, I want to get the content of this surface. But that s not working. instead I always get the content of the last created Surface (in my case it is 9). What do I have to change to get the content of the selected (clicked) surface and not the content of the last created?
here is my Code:
for (f = 0; f < 10; f++) {
var draggable = new Draggable({
xRange: [0, 1000],
yRange: [0, 1000]
});
var surface = new Surface({
size: [true, true],
content: f,
properties:{
fontSize:'16px',
cursor: 'pointer',
borderRadius:'50px',
backgroundColor: '#C0C0C0',
border:'solid'
}
});
surface.on("click",function(){alert(surface.content)});
surface.pipe(draggable);
mainContext.add(draggable).add(surface);
}