Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8349714

Slider allows user to set any value when snapToTicks is true

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx24
    • javafx
    • None

      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.

            angorya Andy Goryachev
            jhendrikx John Hendrikx
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: