JavaFX rounded corners hitbox

Viewed 319

In my program I have styled my buttons using css. I am using "-fx-background-radius" to round the corners and have noticed that when I hover over where the corners used to be it allows me to click the button. I was just wondering if there is a way to make it so that the 'hit-box' for the button matches what you see.

Thank you.

1 Answers

The pickOnBounds property

Defines how the picking computation is done for this node when triggered by a MouseEvent or a contains function call. If pickOnBounds is true, then picking is computed by intersecting with the bounds of this node, else picking is computed by intersecting with the geometric shape of this node.

The "bounds" are essentially the rectangular region containing the node (button in this case). The "geometric shape" accounts for how the node is actually rendered.

So you just need to call setPickOnBounds(false) on the button.

Related