> On Sep 4, 3:49 am, BLACKBING wrote:
>
>> As title, if i create a line or polygon, I want to click it and
>> trigger an event function. Have any idea?
>
> No, you cant do that. If you need sth like that, you need SVG.
Probably a lot of people like me are using canvas because they find
svg unpalatable.
I'm sure there's a way to do it in canvas, though it won't be
easy! :) You'll have to do all the computations yourself to determine
if the clicked coordinate is inside any line or shape you've drawn.
That means you'll have to keep a record of what you've drawn, because
the canvas just remembers pixels, not what commands you used to draw
them. I'll be looking into this myself soon. If I learn anything
useful I'll post my results. For now, here's an interesting document: