changeset 1139:76674fd1bc7e

RT-21289 - Click on ScrollBar inc/dec buttons or track sometimes doesn't work
author mickf
date Thu, 24 May 2012 17:36:51 +0100
parents 36b95b780237
children 7a3adedc3491
files javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ScrollBarBehavior.java
diffstat 1 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ScrollBarBehavior.java	Wed May 23 17:15:15 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ScrollBarBehavior.java	Thu May 24 17:36:51 2012 +0100
@@ -186,9 +186,8 @@
         timeline = new Timeline();
         timeline.setCycleCount(Timeline.INDEFINITE);
 
-        final KeyFrame kf1 = new KeyFrame(
-            Duration.millis(0),
-            new EventHandler<ActionEvent>() {
+        final EventHandler<ActionEvent> step =
+                new EventHandler<ActionEvent>() {
                 @Override
                 public void handle(ActionEvent event) {
                     boolean i = (pos > ((bar.getValue() - bar.getMin())/(bar.getMax() - bar.getMin())));
@@ -203,12 +202,13 @@
                         timeline = null;
                     }
                 }
-            }
-        );
-        final KeyFrame kf2 = new KeyFrame(Duration.millis(200));
-        timeline.getKeyFrames().addAll(kf1, kf2);
+            };
+
+        final KeyFrame kf = new KeyFrame(Duration.millis(200), step);
+        timeline.getKeyFrames().add(kf);
+        // do the first step immediately
         timeline.play();
-
+        step.handle(null);
     }
 
     /**
@@ -235,8 +235,7 @@
         timeline = new Timeline();
         timeline.setCycleCount(Timeline.INDEFINITE);
 
-        final KeyFrame kf1 = new KeyFrame(
-            Duration.millis(0),
+        final EventHandler<ActionEvent> dec =
             new EventHandler<ActionEvent>() {
                 @Override
                 public void handle(ActionEvent event) {
@@ -248,11 +247,13 @@
                         timeline = null;
                     }
                 }
-            }
-        );
-        final KeyFrame kf2 = new KeyFrame(Duration.millis(200));
-        timeline.getKeyFrames().addAll(kf1, kf2);
+            };
+
+        final KeyFrame kf = new KeyFrame(Duration.millis(200), dec);
+        timeline.getKeyFrames().add(kf);
+        // do the first step immediately
         timeline.play();
+        dec.handle(null);
     }
 
     /**
@@ -278,8 +279,7 @@
         timeline = new Timeline();
         timeline.setCycleCount(Timeline.INDEFINITE);
 
-        final KeyFrame kf1 = new KeyFrame(
-            Duration.millis(0),
+        final EventHandler<ActionEvent> inc =
             new EventHandler<ActionEvent>() {
                 @Override
                 public void handle(ActionEvent event) {
@@ -291,11 +291,13 @@
                         timeline = null;
                     }
                 }
-            }
-        );
-        final KeyFrame kf2 = new KeyFrame(Duration.millis(200));
-        timeline.getKeyFrames().addAll(kf1, kf2);
+            };
+
+        final KeyFrame kf = new KeyFrame(Duration.millis(200), inc);
+        timeline.getKeyFrames().add(kf);
+        // do the first step immediately
         timeline.play();
+        inc.handle(null);
     }
 
     /**