changeset 1437:eca72eaec20d

RT-22941 [ScrollBar, touch] knob is moving in wrong direction, when finger swipe is used.
author David Grieve<david.grieve@oracle.com>
date Thu, 12 Jul 2012 16:27:38 -0400
parents a844e4fd4abf
children 32a2ac15cc0e
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java
diffstat 1 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java	Thu Jul 12 16:20:57 2012 -0400
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java	Thu Jul 12 16:27:38 2012 -0400
@@ -284,12 +284,27 @@
 
                     double delta = (getSkinnable().getOrientation() == Orientation.VERTICAL ? dy : dx);
 
-                    if (delta > 0.0 && sb.getValue() > sb.getMin()) {
-                        sb.decrement();
-                        event.consume();
-                    } else if (delta < 0.0 && sb.getValue() < sb.getMax()) {
-                        sb.increment();
-                        event.consume();
+                    /*
+                    ** RT-22941 - If this is either a touch or inertia scroll
+                    ** then we move to the position of the touch point.
+                    *
+                    * TODO: this fix causes RT-23406 ([ScrollBar, touch] Dragging scrollbar from the 
+                    * track on touchscreen causes flickering)
+                    */
+                    if (event.isDirect()) {
+                        if (trackLength > thumbLength) {
+                            getBehavior().thumbDragged(null, (getSkinnable().getOrientation() == Orientation.VERTICAL ? event.getY(): event.getX()) / trackLength);
+                            event.consume();
+                        }
+                    }
+                    else {
+                        if (delta > 0.0 && sb.getValue() > sb.getMin()) {
+                            sb.decrement();
+                            event.consume();
+                        } else if (delta < 0.0 && sb.getValue() < sb.getMax()) {
+                            sb.increment();
+                            event.consume();
+                        }
                     }
                 }
             }