changeset 1422:a8bd152f64ad

RT-20222 : Ensemble - Controls on the right side are not reachable via keyboard
author mickf
date Mon, 09 Jul 2012 18:17:55 +0100
parents f3bb020babab
children 1eadff96bc2b
files javafx-ui-common/src/com/sun/javafx/scene/traversal/ContainerTabOrder.java javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TabPaneBehavior.java
diffstat 2 files changed, 46 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/scene/traversal/ContainerTabOrder.java	Mon Jul 09 18:12:23 2012 +0100
+++ b/javafx-ui-common/src/com/sun/javafx/scene/traversal/ContainerTabOrder.java	Mon Jul 09 18:17:55 2012 +0100
@@ -157,7 +157,7 @@
         for (int i = startIndex ; i < nodeList.size() ; i++) {
 
             Node nextNode = nodeList.get(i);
-            if (nextNode.isFocusTraversable() == true && nextNode.isDisabled() == false && nextNode.isVisible() == true) {
+            if (nextNode.isFocusTraversable() == true && nextNode.isDisabled() == false && nextNode.impl_isTreeVisible() == true) {
                 newNode = nextNode;
                 break;
             }
@@ -233,7 +233,7 @@
 
         for (int i = startIndex ; i >= 0 ; i--) {
             Node prevNode = nodeList.get(i);
-            if (prevNode.isFocusTraversable() == true && prevNode.isDisabled() == false && prevNode.isVisible() == true) {
+            if (prevNode.isFocusTraversable() == true && prevNode.isDisabled() == false && prevNode.impl_isTreeVisible() == true) {
                 newNode = prevNode;
                 break;
             }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TabPaneBehavior.java	Mon Jul 09 18:12:23 2012 +0100
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/TabPaneBehavior.java	Mon Jul 09 18:17:55 2012 +0100
@@ -27,7 +27,10 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javafx.collections.ObservableList;
 import javafx.event.Event;
+import javafx.scene.Parent;
+import javafx.scene.Node;
 import javafx.scene.control.Tab;
 import javafx.scene.control.TabPane;
 import javafx.scene.input.KeyCode;
@@ -80,7 +83,26 @@
             if (tps.getSelectedTabContentRegion() != null) {
                 tps.getSelectedTabContentRegion().getImpl_traversalEngine().getTopLeftFocusableNode();
                 if (tps.getSelectedTabContentRegion().getImpl_traversalEngine().registeredNodes.isEmpty()) {
-                    super.callAction(name);
+
+                    Parent traversableParent = null;
+                    traversableParent = getFirstPopulatedInnerTraversalEngine(tps.getSelectedTabContentRegion().getChildren());
+                    if (traversableParent != null) {
+                        boolean nodeFound = false;
+                        for (Node n : traversableParent.getImpl_traversalEngine().registeredNodes) {
+                            if (!n.isFocused() && n.impl_isTreeVisible() && !n.isDisabled()) {
+                                n.requestFocus();
+                                nodeFound = true;
+                                break;
+                            }
+                        }
+                        if (nodeFound == false) {
+                            super.callAction(name);
+                        }
+                    }
+                    else {
+                        super.callAction(name);
+                    }
+
                 }
             } else {
                 super.callAction(name);
@@ -114,6 +136,27 @@
         }
     }
 
+
+    public static Parent getFirstPopulatedInnerTraversalEngine(ObservableList<Node> root) {
+        Parent firstPopulatedEngine = null;
+        for (Node node : root) {
+            if (node instanceof Parent) {
+                if (((Parent)node).getImpl_traversalEngine() != null && !((Parent)node).getImpl_traversalEngine().registeredNodes.isEmpty()) {
+                    firstPopulatedEngine = (Parent)node;
+                    break;
+                }
+                else {
+                    firstPopulatedEngine = getFirstPopulatedInnerTraversalEngine(((Parent)node).getChildrenUnmodifiable());
+                    if (firstPopulatedEngine != null) {
+                        break;
+                    }
+                }
+            }
+        }
+        return firstPopulatedEngine;
+    }
+
+
     /***************************************************************************
      *                                                                         *
      * Mouse event handling                                                    *