16
votes

When I create an svg rect with "fill: black", my on_click event handler gets called.

When I replace the "fill: black" with "fill: none", my event handler is NOT called when I click inside the rect, but only called when I click on the border of the rect.

Question: what do I need to change so that click events are detected for clicking inside the rectangle?

1

1 Answers

28
votes

This is controlled by the pointer-events property. Looks like you want to set it to visible

<rect pointer-events="visible" ...>