changeset 1120:ece88055a0d4

fix RT-21548 left/right/up/down dont work for custom colors in palette
author Paru Somashekar <paru.somashekar@oracle.com>
date Tue, 22 May 2012 16:09:39 -0700
parents e8b3ea91cdd6
children 5fd78b9689d5
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPalette.java
diffstat 1 files changed, 64 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPalette.java	Tue May 22 15:40:09 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPalette.java	Tue May 22 16:09:39 2012 -0700
@@ -209,7 +209,19 @@
                                     (index-1) : (NUM_OF_ROWS*NUM_OF_COLUMNS)-1);
                 prevSquare.requestFocus();
                 focusedSquare = prevSquare;
-                break;
+                return;
+            } 
+        }
+        // check custom colors
+        int len = customColorGrid.getChildren().size();
+        for (index = len-1; index >= 0; index--) {
+            ColorSquare cs = (ColorSquare)customColorGrid.getChildren().get(index);
+            if (cs == focusedSquare) {
+                ColorSquare prevSquare = (ColorSquare)customColorGrid.getChildren().get((index != 0) ? 
+                                    (index-1) : len-1);
+                prevSquare.requestFocus();
+                focusedSquare = prevSquare;
+                return;
             } 
         }
         if (index == -1) {
@@ -228,9 +240,26 @@
                         (index-12) : ((NUM_OF_ROWS-1)*NUM_OF_COLUMNS)+index);
                 prevSquare.requestFocus();
                 focusedSquare = prevSquare;
-                break;
+                return;
             } 
         }
+        int len = customColorGrid.getChildren().size();
+        for (index = len-1; index >= 0; index--) {
+            // check custom colors
+            ColorSquare cs = (ColorSquare)customColorGrid.getChildren().get(index);
+            ColorSquare prevSquare = null;
+            if (cs == focusedSquare) {
+                if (index -12 >= 0) {
+                    prevSquare = (ColorSquare)customColorGrid.getChildren().get(index-12);
+                } else {
+                    int rowIndex = customColorGrid.getRowIndex(customColorGrid.getChildren().get(len-1));
+                    prevSquare = (ColorSquare)customColorGrid.getChildren().get((rowIndex*NUM_OF_COLUMNS)+index);
+                }
+                prevSquare.requestFocus();
+                focusedSquare = prevSquare;
+                return;
+            }
+        }
         if (index == -1) {
             ColorSquare cs = colorPickerGrid.getSquares().get((NUM_OF_ROWS*NUM_OF_COLUMNS)-1);
             focusedSquare = cs;
@@ -247,10 +276,22 @@
                         (index != (NUM_OF_ROWS*NUM_OF_COLUMNS)-1) ? (index+1) : 0);
                 prevSquare.requestFocus();
                 focusedSquare = prevSquare;
-                break;
+                return;
             } 
         }
-        if (index == (NUM_OF_ROWS*NUM_OF_COLUMNS)) {
+        // check custom colors
+        int len = customColorGrid.getChildren().size();
+        for (index = 0; index < len; index++) {
+            ColorSquare cs = (ColorSquare)customColorGrid.getChildren().get(index);
+            if (cs == focusedSquare) {
+                ColorSquare prevSquare = (ColorSquare)customColorGrid.getChildren().get(
+                        (index != len-1) ? (index+1) : 0);
+                prevSquare.requestFocus();
+                focusedSquare = prevSquare;
+                return;
+            } 
+        }
+        if (index == len) {
             ColorSquare cs = colorPickerGrid.getSquares().get(0);
             focusedSquare = cs;
             focusedSquare.requestFocus();
@@ -266,10 +307,27 @@
                         (index+12) : index-((NUM_OF_ROWS-1)*NUM_OF_COLUMNS));
                 prevSquare.requestFocus();
                 focusedSquare = prevSquare;
-                break;
+                return;
             } 
         }
-        if (index == (NUM_OF_ROWS*NUM_OF_COLUMNS)) {
+        // check custom colors
+        int len = customColorGrid.getChildren().size();
+        for (index = 0; index < len; index++) {
+            ColorSquare cs = (ColorSquare)customColorGrid.getChildren().get(index);
+            ColorSquare prevSquare = null;
+            if (cs == focusedSquare) {
+                if (index+12 < len) {
+                    prevSquare = (ColorSquare)customColorGrid.getChildren().get(index+12);
+                } else {
+                    int rowIndex = customColorGrid.getRowIndex(customColorGrid.getChildren().get(len-1));
+                    prevSquare = (ColorSquare)customColorGrid.getChildren().get(index-(rowIndex)*NUM_OF_COLUMNS);
+                }
+                prevSquare.requestFocus();
+                focusedSquare = prevSquare;
+                return;
+            } 
+        }
+        if (index == len) {
             ColorSquare cs = colorPickerGrid.getSquares().get(0);
             focusedSquare.requestFocus();
             focusedSquare = cs;