@@ -280,9 +280,6 @@ public MenuScroller(JPopupMenu menu, int scrollCount, int interval,
280280 scrollCount = autoSizeScrollCount ;
281281 }
282282
283- // if (PreferencesData.getBoolean("ide.accessible")) {
284- // interval = 1000;
285- // }
286283 if (scrollCount <= 0 || interval <= 0 ) {
287284 throw new IllegalArgumentException ("scrollCount and interval must be greater than 0" );
288285 }
@@ -573,8 +570,21 @@ public void actionPerformed(ActionEvent e) {
573570 firstIndex += increment * accelerator ;
574571 refreshMenu ();
575572 if (PreferencesData .getBoolean ("ide.accessible" )) {
573+ // If the user has chosen to use accessibility features, it means that they are using a screen reader
574+ // to assist them in development of their project. This scroller is very unfriendly toward screen readers
575+ // because it does not tell the user that it is scrolling through the board options, and it does not read
576+ // the name of the boards as they scroll by. It is possible that the desired board will never become
577+ // accessible.
578+ // Because this scroller is quite nice for the sighted user, the idea here is to continue to use the
579+ // scroller, but to fool it into scrolling one item at a time for accessible features users so that the
580+ // screen readers work well, too.
581+ // It's not the prettiest of code, but it works.
576582 String itemClassName ;
577583 int keyEvent ;
584+
585+ // The blind user likely used an arrow key to get to the scroller. Determine which arrow key
586+ // so we can send an event for the opposite arrow key. This fools the scroller into scrolling
587+ // a single item. Get the class name of the new item while we're here
578588 if (increment > 0 ) {
579589 itemClassName = menuItems [firstIndex + scrollCount - 1 ].getClass ().getName ();
580590 keyEvent = KeyEvent .VK_UP ;
@@ -584,8 +594,9 @@ public void actionPerformed(ActionEvent e) {
584594 keyEvent = KeyEvent .VK_DOWN ;
585595 }
586596
587- // if next item is a separator just go on like normal, otherwise move the cursor back to that item is read
588- // by a screen reader and the user can continue to use their arrow keys to navigate the list
597+ // Use the class name to check if the next item is a separator. If it is, just let it scroll on like
598+ // normal, otherwise move the cursor back with the opposite key event to the new item so that item is read
599+ // by a screen reader and the user can use their arrow keys to navigate the list one item at a time
589600 if (!itemClassName .equals (JSeparator .class .getName ()) ) {
590601 KeyboardFocusManager manager = KeyboardFocusManager .getCurrentKeyboardFocusManager ();
591602 Component comp = manager .getFocusOwner ();
0 commit comments