From ef0cbe80ccb73f6dd18df13dd78c48b47afdcaed Mon Sep 17 00:00:00 2001 From: Pedro Duque Vieira Date: Sun, 18 Aug 2019 23:52:44 +0100 Subject: [PATCH] SliderSkin: re-add fill when tick marks properties change --- .../java/impl/jfxtras/styles/jmetro/SliderSkin.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jmetro/src/main/java/impl/jfxtras/styles/jmetro/SliderSkin.java b/jmetro/src/main/java/impl/jfxtras/styles/jmetro/SliderSkin.java index f2a6727f..1f324b58 100644 --- a/jmetro/src/main/java/impl/jfxtras/styles/jmetro/SliderSkin.java +++ b/jmetro/src/main/java/impl/jfxtras/styles/jmetro/SliderSkin.java @@ -2,6 +2,7 @@ import javafx.animation.FadeTransition; import javafx.beans.property.BooleanProperty; +import javafx.beans.value.ObservableValue; import javafx.css.CssMetaData; import javafx.css.SimpleStyleableBooleanProperty; import javafx.css.Styleable; @@ -51,6 +52,18 @@ public SliderSkin(Slider control) { thumb.addEventHandler(MouseEvent.MOUSE_PRESSED, this::mousePressedOnThumb); thumb.addEventHandler(MouseEvent.MOUSE_DRAGGED, this::mouseDraggedOnThumb); thumb.addEventHandler(MouseEvent.MOUSE_RELEASED, this::mouseReleasedFromThumb); + + registerChangeListener(control.showTickMarksProperty(), this::thickMarksChanged); + registerChangeListener(control.showTickLabelsProperty(), this::thickMarksChanged); + } + + private void thickMarksChanged(ObservableValue observableValue) { + /* When this method is called setShowTickMarks of super class has already been called + on that method the children's list has been cleared so we need to re-add any Nodes that this Class adds + to the Slider */ + + // Add fill right above track + getChildren().add(getChildren().indexOf(track) + 1, fill); } private void mousePressedOnTrack(MouseEvent mouseEvent) {