Skip to content

Commit

Permalink
SliderSkin: re-add fill when tick marks properties change
Browse files Browse the repository at this point in the history
  • Loading branch information
dukke committed Aug 18, 2019
1 parent 40d39b4 commit ef0cbe8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions jmetro/src/main/java/impl/jfxtras/styles/jmetro/SliderSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ef0cbe8

Please sign in to comment.