I\'m implementing a toolbox-like pane, so user can only pick one tool at a time, and I switched from Button to RadioButton for its behavior.
Finally I went with another way around. You can extend ToggleButton so that it behaves like a RadioButton. This does not have the weird click effect of consuming mouse release.
public class RadioToggleButton extends ToggleButton {
// As in RadioButton.
/**
* Toggles the state of the radio button if and only if the RadioButton
* has not already selected or is not part of a {@link ToggleGroup}.
*/
@Override
public void fire() {
// we don't toggle from selected to not selected if part of a group
if (getToggleGroup() == null || !isSelected()) {
super.fire();
}
}
}
Then in FXML:
And it is done.