changeset 2871:fd29ff6315e7

RT-23427 : [ScrollBar] NPE in mouse event processing.
author mickf
date Mon, 11 Mar 2013 15:01:11 +0000
parents 02a668fbc3b6
children 36fcf9f812ed
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java	Mon Mar 11 15:57:29 2013 +1300
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java	Mon Mar 11 15:01:11 2013 +0000
@@ -210,6 +210,10 @@
                     */
                     if (trackLength > thumbLength) {
                         Point2D cur = thumb.localToParent(me.getX(), me.getY());
+                        if (dragStart == null) {
+                            // we're getting dragged without getting a mouse press
+                            dragStart = thumb.localToParent(me.getX(), me.getY());
+                        }
                         double dragPos = getSkinnable().getOrientation() == Orientation.VERTICAL ? cur.getY() - dragStart.getY(): cur.getX() - dragStart.getX();
                         getBehavior().thumbDragged(me, preDragThumbPos + dragPos / (trackLength - thumbLength));
                     }
@@ -247,6 +251,10 @@
                         */
                         if (trackLength > thumbLength) {
                             Point2D cur = thumb.localToParent(event.getX(), event.getY());
+                            if (dragStart == null) {
+                                // we're getting dragged without getting a mouse press
+                                dragStart = thumb.localToParent(event.getX(), event.getY());
+                            }
                             double dragPos = getSkinnable().getOrientation() == Orientation.VERTICAL ? cur.getY() - dragStart.getY(): cur.getX() - dragStart.getX();
                             getBehavior().thumbDragged(null/*todo*/, preDragThumbPos + dragPos / (trackLength - thumbLength));
                         }