Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessibility: ScrollView to auto scroll to the view which are not visible on hitting "TAB"

Could someone let me know how can I automatically scroll the scrollView when a keyboard-only user tries to navigate between different UI Element in the ScrollView using ‘Tab’ key? When I hit "TAB" key the focus is shifted to different UI element present in the scrollView but it doesn't scroll if the UI Element is not present in the Visible Content View. How can this be achieved. Help would be appreciated. Thanks.

like image 790
Rahul Singh Avatar asked Dec 14 '17 10:12

Rahul Singh


People also ask

How do I prevent a tab from scrolling to the top?

By default a tab press does several things: If the screen for the tab renders a scroll view, you can use useScrollToTop to scroll it to top If the screen for the tab renders a stack navigator, a popToTop action is performed on the stack To prevent the default behavior, you can call event.preventDefault:

What is Tabtab scrolling and how to enable it?

Tab Scrolling is not a feature that Microsoft added to the browser; instead, it is a feature that is added to the Chromium core. You can enable it in Google Chrome development versions right now, but when you check the flags page in Edge, you will notice that the flag is missing.

Is it possible to scroll back up with tabnavigator V2?

Yet, in order to be able to scroll back up, I wrap all the page content (including the navigator) in a ScrollView. When using v2, the TabNavigator would expand to its content size, thus making it visible without having to implement a scrollview in the screens of the navigator.

How do I scroll the tabs in Microsoft Edge?

By default, tabs get smaller and smaller the more you open, but there is no option to scroll them. Microsoft did introduce support for vertical tabs in the recent release of Edge 89 Stable, and the feature is suggested to users when too many tabs are opened.


1 Answers

Solution A: Create a subclass of NSWindow and override makeFirstResponder:. makeFirstResponder is called when the first responder changes.

- (BOOL)makeFirstResponder:(NSResponder *)responder {
    BOOL madeFirstResponder = [super makeFirstResponder:responder];
    if (madeFirstResponder) {
        id view = [self firstResponder];
        // check if the new first responder is a field editor
        if (view && [view isKindOfClass:[NSTextView class]] && [view isFieldEditor])
            view = [view delegate]; // the control, usually a NSTextField
        if (view && [view isKindOfClass:[NSControl class]] && [view enclosingScrollView]) {
            NSRect rect = [view bounds];
            rect = NSInsetRect(rect, -10.0, -10.0); // add a margin
            [view scrollRectToVisible:rect];
        }
    }
    return madeFirstResponder;
}

Solution B: Create a subclass of NSTextField and other controls and override becomeFirstResponder.

- (BOOL)becomeFirstResponder {
    BOOL becameFirstResponder = [super becomeFirstResponder];
    if (becameFirstResponder) {
        if ([self enclosingScrollView]) {
            NSRect rect = [self bounds];
            rect = NSInsetRect(rect, -10.0, -10.0); // add a margin
            [self scrollRectToVisible:rect];
        }
    }
    return becameFirstResponder;
}
like image 74
Willeke Avatar answered Nov 15 '22 06:11

Willeke