Search code examples
svgjavafxcustom-controlscss-shapes

Mouse Events on a Region with custom shape in JavaFX 8


I'm trying to make a custom control in JavaFX 8 by usigin a Region and its css property -fx-shape to set a custom svg path to the Region. Then i tried to adding some Mouse Click handling, but the problem is that MouseClick Events are fired on all the Region, not only when clicking inside the shape defined in css. How can I solve this problem? Thank you!


Solution

  • Try

    region.setPickOnBounds(false);