I’ve created a custom Shape, whose shape is actually defined by a geometry definition, such as the following:
var shape = $$(go.Shape, {
stroke: colours.white,
strokeWidth: 2,
geometryStretch: go.GraphObject.None,
stretch: go.GraphObject.None,
fill: colours.light_gray,
alignment: go.Spot.TopLeft,
alignmentFocus: go.Spot.TopLeft,
geometry: new go.Geometry()
.add(new go.PathFigure(0, 40) // start point
.add(new go.PathSegment(go.PathSegment.Arc,
start, perSegment, // angles
0, 40, // center
40, 40) // radius
.close()))
});
When I set a click listener to this shape, it works as expected. However, the click listener is called even when the the click occurs outside the arc. I understand that this is because the shape is represented as a bounding rectangle, and that any clicks within that bounding rectangle will trigger the click event.
How do I create a shape such that mouse events are triggered only from within the closed path of the geometry defined?
EDIT: Sorry, I had a typo in my code - I was setting the click listener over the containing panel. However, after setting it to the shape that I created, the click events don’t seem to be triggered at all. What could be the problem here?