|
23 | 23 | import javafx.animation.KeyValue; |
24 | 24 | import javafx.animation.Timeline; |
25 | 25 | import javafx.beans.binding.Bindings; |
| 26 | +import javafx.beans.binding.BooleanBinding; |
26 | 27 | import javafx.beans.binding.NumberBinding; |
27 | | -import javafx.beans.value.ChangeListener; |
28 | 28 | import javafx.geometry.Orientation; |
29 | 29 | import javafx.geometry.Point2D; |
30 | 30 | import javafx.scene.Node; |
|
43 | 43 | public class FloatScrollBarSkin implements Skin<ScrollBar> { |
44 | 44 | private ScrollBar scrollBar; |
45 | 45 | private Region group; |
46 | | - private Rectangle track = new Rectangle(); |
47 | | - private Rectangle thumb = new Rectangle(); |
| 46 | + private final Rectangle track = new Rectangle(); |
| 47 | + private final Rectangle thumb = new Rectangle(); |
48 | 48 |
|
49 | | - @SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal"}) |
50 | | - private ChangeListener<Boolean> thumbHoverListener; |
| 49 | + private BooleanBinding hoverOrPressed; |
51 | 50 | private Animation thumbHoverAnimation; |
52 | 51 |
|
53 | 52 | public FloatScrollBarSkin(final ScrollBar scrollBar) { |
@@ -214,7 +213,8 @@ protected double computeMaxHeight(double width) { |
214 | 213 | } |
215 | 214 | }; |
216 | 215 |
|
217 | | - this.thumbHoverListener = FXUtils.onWeakChangeAndOperate(thumb.hoverProperty(), newValue -> { |
| 216 | + this.hoverOrPressed = thumb.hoverProperty().or(thumb.pressedProperty()); |
| 217 | + FXUtils.onChangeAndOperate(hoverOrPressed, newValue -> { |
218 | 218 | if (thumbHoverAnimation != null) { |
219 | 219 | thumbHoverAnimation.stop(); |
220 | 220 | thumbHoverAnimation = null; |
@@ -249,7 +249,7 @@ public void dispose() { |
249 | 249 | thumbHoverAnimation.stop(); |
250 | 250 | thumbHoverAnimation = null; |
251 | 251 | } |
252 | | - thumbHoverListener = null; |
| 252 | + hoverOrPressed = null; |
253 | 253 | scrollBar = null; |
254 | 254 | group = null; |
255 | 255 | } |
|
0 commit comments