< prev index next >

modules/javafx.controls/src/main/java/javafx/scene/control/skin/MenuBarSkin.java

Print this page




1046     }
1047 
1048     private void menuModeStart(int newIndex) {
1049         if (focusedMenuIndex == -1) {
1050             SceneHelper.getSceneAccessor().setTransientFocusContainer(getSkinnable().getScene(), getSkinnable());
1051         }
1052         setFocusedMenuIndex(newIndex);
1053     }
1054 
1055     private void menuModeEnd() {
1056         if (focusedMenuIndex != -1) {
1057             SceneHelper.getSceneAccessor().setTransientFocusContainer(getSkinnable().getScene(), null);
1058 
1059             /* Return the a11y focus to a control in the scene. */
1060             getSkinnable().notifyAccessibleAttributeChanged(AccessibleAttribute.FOCUS_NODE);
1061         }
1062         setFocusedMenuIndex(-1);
1063     }
1064 
1065     private void moveToMenu(Direction dir, boolean doShow) {

1066         findSibling(dir, focusedMenuIndex).ifPresent(p -> {
1067             setFocusedMenuIndex(p.getValue());
1068             if (doShow) {
1069                 showMenu(p.getKey(), true);
1070             }
1071         });
1072     }
1073 
1074     private Optional<Pair<Menu,Integer>> findSibling(Direction dir, int startIndex) {
1075         final int childCount = container.getChildren().size();
1076         int nextIndex = startIndex;
1077         if (nextIndex == -1) return Optional.empty();
1078         if (dir.isForward() && nextIndex == childCount - 1) {
1079             // loop forwards to start
1080             nextIndex = 0;
1081         } else if (!dir.isForward() && nextIndex == 0) {
1082             // loop backwards to end
1083             nextIndex = childCount - 1;
1084         } else {
1085             nextIndex += dir.isForward() ? 1 : -1;
1086         }
1087         // RT_19359
1088         if (getSkinnable().getMenus().get(nextIndex).isDisable()) return findSibling(dir, nextIndex);




1046     }
1047 
1048     private void menuModeStart(int newIndex) {
1049         if (focusedMenuIndex == -1) {
1050             SceneHelper.getSceneAccessor().setTransientFocusContainer(getSkinnable().getScene(), getSkinnable());
1051         }
1052         setFocusedMenuIndex(newIndex);
1053     }
1054 
1055     private void menuModeEnd() {
1056         if (focusedMenuIndex != -1) {
1057             SceneHelper.getSceneAccessor().setTransientFocusContainer(getSkinnable().getScene(), null);
1058 
1059             /* Return the a11y focus to a control in the scene. */
1060             getSkinnable().notifyAccessibleAttributeChanged(AccessibleAttribute.FOCUS_NODE);
1061         }
1062         setFocusedMenuIndex(-1);
1063     }
1064 
1065     private void moveToMenu(Direction dir, boolean doShow) {
1066         boolean showNextMenu = doShow && focusedMenu.isShowing();
1067         findSibling(dir, focusedMenuIndex).ifPresent(p -> {
1068             setFocusedMenuIndex(p.getValue());
1069             if (showNextMenu) {
1070                 showMenu(p.getKey(), true);
1071             }
1072         });
1073     }
1074 
1075     private Optional<Pair<Menu,Integer>> findSibling(Direction dir, int startIndex) {
1076         final int childCount = container.getChildren().size();
1077         int nextIndex = startIndex;
1078         if (nextIndex == -1) return Optional.empty();
1079         if (dir.isForward() && nextIndex == childCount - 1) {
1080             // loop forwards to start
1081             nextIndex = 0;
1082         } else if (!dir.isForward() && nextIndex == 0) {
1083             // loop backwards to end
1084             nextIndex = childCount - 1;
1085         } else {
1086             nextIndex += dir.isForward() ? 1 : -1;
1087         }
1088         // RT_19359
1089         if (getSkinnable().getMenus().get(nextIndex).isDisable()) return findSibling(dir, nextIndex);


< prev index next >