diff options
author | Anastasia Smirnova <anasmi@utu.fi> | 2019-04-10 16:17:18 +0300 |
---|---|---|
committer | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2019-04-10 16:17:18 +0300 |
commit | 258450a82b61b1582905978433b8ed23575924b8 (patch) | |
tree | a410f391ff9889e475a88b94bad4c7e24c73d49f /server | |
parent | 7392bf241f115a9a338e047187be1b1d1ddfaed6 (diff) | |
download | vaadin-framework-258450a82b61b1582905978433b8ed23575924b8.tar.gz vaadin-framework-258450a82b61b1582905978433b8ed23575924b8.zip |
Clicking on slider makes handler move (#11519)
* Clicking on slider makes handler move
Fixes #1496
* Introducing control over clicking behaviour
- User will have to enable process of the click event on handle calling `slider.setEnableClickHandler(true);`
- Clean-up the handler logic in VSlider.java
- Renaming the property to `updateValueOnClick`
- Added JavaDocs
- Fixing tests
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Slider.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Slider.java b/server/src/main/java/com/vaadin/ui/Slider.java index c488ecca52..2c1ec4afa1 100644 --- a/server/src/main/java/com/vaadin/ui/Slider.java +++ b/server/src/main/java/com/vaadin/ui/Slider.java @@ -258,6 +258,31 @@ public class Slider extends AbstractField<Double> { getState().resolution = resolution; } + /** + * Sets the slider to update its value when the user clicks on it. + * By default, the slider value is updated by dragging the slider's handle + * or clicking arrows. + * + * @param updateValueOnClick + * {@code true} to update the value of the slider on click, + * {@code false} otherwise. + * @since + */ + public void setUpdateValueOnClick(boolean updateValueOnClick) { + getState().updateValueOnClick = updateValueOnClick; + } + + /** + * Returns whether the slider updates its value on user click. + * + * @return {@code true} if the Slider updates its value on click. By + * default, returns {@code false} + * @since + */ + public boolean isUpdateValueOnClick() { + return getState(false).updateValueOnClick; + } + private double getRoundedValue(Double value) { final double v = value.doubleValue(); final int resolution = getResolution(); |