For some reason, the value property accepts any value for Sliders, not even respecting min/max values. There is a secondary method called `adjustValue` that does the right thing (clamping between min and max and honouring snapToTicks).
The `adjustValue` method however comes with a dire warning:
* Note: This function is intended to be used by experts, primarily
* by those implementing new Skins or Behaviors. It is not common
* for developers or designers to access this function directly.
This makes no sense. IMHO this method should not exist, and `setValue` should do what `adjustValue` does already. This can trivially be achieved by overriding `set` in the value property:
@Override
public void set(double v) {
super.set(snapValueToTicks(v));
}
Note that the Slider control currently leaves this up to the Behavior to enforce, which IMHO is the absolute wrong place to do this. SnapToTicks is a property of the control, and when set, should not be ignorable by any installed Behavior, nor the programmer by using `setValue` directly.
The `adjustValue` method however comes with a dire warning:
* Note: This function is intended to be used by experts, primarily
* by those implementing new Skins or Behaviors. It is not common
* for developers or designers to access this function directly.
This makes no sense. IMHO this method should not exist, and `setValue` should do what `adjustValue` does already. This can trivially be achieved by overriding `set` in the value property:
@Override
public void set(double v) {
super.set(snapValueToTicks(v));
}
Note that the Slider control currently leaves this up to the Behavior to enforce, which IMHO is the absolute wrong place to do this. SnapToTicks is a property of the control, and when set, should not be ignorable by any installed Behavior, nor the programmer by using `setValue` directly.
- blocks
-
JDK-8349685 ☂ Slider bug collection
-
- Open
-