I have drawn a shape using two.js and I want to write code to handle click events on that shape. Not the canvas, but on the shape itself.
front_left.domElement = $('#two-' + front_left.id)
.css('cursor', 'pointer')
.click(function(e){
alert("Hello World!");
});
This code taken from an answer that seems like it should work:
circle.domElement = $('#two-' + circle.id)
.css('cursor', 'pointer')
.click(function(e) {
circle.fill = getNonMainRandomColor(getRandomColor());
});
but it doesn't work for me using the latest JQuery and the latest two.js, and it also doesn't seem to work in the example, since the code reads as if clicking on the circles was supposed to make the colour changes but nothing happens on any browser or computer I've tried.
So, how can I capture and respond to click events of shapes/groups drawn with two.js?