diff options
author | Juuxel <kasperi.kauppi@gmail.com> | 2019-09-01 11:00:24 +0300 |
---|---|---|
committer | Juuxel <kasperi.kauppi@gmail.com> | 2019-09-01 11:00:24 +0300 |
commit | 5588ac161cc269e4368f7b762da9deb496bf5f62 (patch) | |
tree | 0fbb7a96e0ce3f163c447ad630eca298503c7ad6 | |
parent | 4587fc8700462a939ae5ee5cd81a2ff176880001 (diff) | |
download | LibGui-5588ac161cc269e4368f7b762da9deb496bf5f62.tar.gz LibGui-5588ac161cc269e4368f7b762da9deb496bf5f62.tar.bz2 LibGui-5588ac161cc269e4368f7b762da9deb496bf5f62.zip |
Clamp slider values in WAbstractSlider.setValue
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java index e07be56..f4ef1eb 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java @@ -170,8 +170,11 @@ public abstract class WAbstractSlider extends WWidget { } public void setValue(int value) { - this.value = value; - onValueChanged(value); + int previous = this.value; + this.value = MathHelper.clamp(value, min, max); + if (previous != this.value) { + onValueChanged(this.value); + } } @Nullable |