changeset 5186:8319071566e7

RT-32380 - ScrollPane: Content does not scroll using keyboard, reviewed by David
author mickf
date Tue, 01 Oct 2013 14:57:31 +0100
parents 5a67a3c94fee
children 6039c1e69ed7
files modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ScrollPaneBehavior.java
diffstat 1 files changed, 22 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ScrollPaneBehavior.java	Tue Oct 01 14:38:27 2013 +0100
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ScrollPaneBehavior.java	Tue Oct 01 14:57:31 2013 +0100
@@ -43,6 +43,8 @@
 import static javafx.scene.input.KeyCode.RIGHT;
 import static javafx.scene.input.KeyCode.SPACE;
 import static javafx.scene.input.KeyCode.UP;
+import static javafx.scene.input.KeyCode.HOME;
+import static javafx.scene.input.KeyCode.END;
 
 
 /**
@@ -95,6 +97,15 @@
     void verticalPageDecrement() {
         ((ScrollPaneSkin)getControl().getSkin()).vsbPageDecrement();
     }
+    void verticalHome() {
+        ((ScrollPane)getControl()).setHvalue(((ScrollPane)getControl()).getHmin());
+        ((ScrollPane)getControl()).setVvalue(((ScrollPane)getControl()).getVmin());
+    }
+    void verticalEnd() {
+        ((ScrollPane)getControl()).setHvalue(((ScrollPane)getControl()).getHmax());
+        ((ScrollPane)getControl()).setVvalue(((ScrollPane)getControl()).getVmax());
+    }
+
 
     public void contentDragged(double deltaX, double deltaY) {
         // negative when dragged to the right/bottom
@@ -123,15 +134,18 @@
         // TODO XXX DEBUGGING ONLY
         SCROLL_PANE_BINDINGS.add(new KeyBinding(F4, "TraverseDebug").alt().ctrl().shift());
 
-        SCROLL_PANE_BINDINGS.add(new ScrollViewKeyBinding(LEFT, "HorizontalUnitDecrement"));
-        SCROLL_PANE_BINDINGS.add(new ScrollViewKeyBinding(RIGHT, "HorizontalUnitIncrement"));
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(LEFT, "HorizontalUnitDecrement"));
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(RIGHT, "HorizontalUnitIncrement"));
 
-        SCROLL_PANE_BINDINGS.add(new ScrollViewKeyBinding(UP, "VerticalUnitDecrement"));
-        SCROLL_PANE_BINDINGS.add(new ScrollViewKeyBinding(DOWN, "VerticalUnitIncrement"));
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(UP, "VerticalUnitDecrement"));
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(DOWN, "VerticalUnitIncrement"));
 
-        SCROLL_PANE_BINDINGS.add(new ScrollViewKeyBinding(PAGE_UP, "VerticalPageDecrement"));
-        SCROLL_PANE_BINDINGS.add(new ScrollViewKeyBinding(PAGE_DOWN, "VerticalPageIncrement"));
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(PAGE_UP, "VerticalPageDecrement"));
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(PAGE_DOWN, "VerticalPageIncrement"));
         SCROLL_PANE_BINDINGS.add(new KeyBinding(SPACE, "VerticalPageIncrement"));
+
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(HOME, "VerticalHome"));
+        SCROLL_PANE_BINDINGS.add(new KeyBinding(END, "VerticalEnd"));
     }
 
     protected /*final*/ String matchActionForEvent(KeyEvent e) {
@@ -158,6 +172,8 @@
         else if ("VerticalUnitIncrement".equals(name)) verticalUnitIncrement();
         else if ("VerticalPageDecrement".equals(name)) verticalPageDecrement();
         else if ("VerticalPageIncrement".equals(name)) verticalPageIncrement();
+        else if ("VerticalHome".equals(name)) verticalHome();
+        else if ("VerticalEnd".equals(name)) verticalEnd();
         else super.callAction(name);
     }
 
@@ -175,20 +191,4 @@
         super.mousePressed(e);
         getControl().requestFocus();
     }
-
-    /**
-     * Class to handle key bindings based upon the orientation of the control.
-     */
-    public static class ScrollViewKeyBinding extends OrientedKeyBinding {
-        public ScrollViewKeyBinding(KeyCode code, String action) {
-            super(code, action);
-        }
-
-        public ScrollViewKeyBinding(KeyCode code, EventType<KeyEvent> type, String action) {
-            super(code, type, action);
-        }
-        public @Override boolean getVertical(Control control) {
-            return true;
-        }
-    }
 }