From f4e2de14f2c20c8f1ef84f3d8bb6308f9e565d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Dus=CC=8Cek?= Date: Sat, 2 Mar 2013 16:27:10 +0100 Subject: [PATCH] Present the document view as a group to VoiceOver/accessibility This enables VoiceOver user to see the document view as a single element and interact with it (i.e. inspect its subelements) only when needed by using the VO-Shift-down shortcut (and stop interacting with it using VO-Shift-up shortcut). This makes the element structure more hierarchical where at the top level are only major user interface components, so that it's easier for orientation. It also prevents unrelated UI elements to be sequential as VoiceOver by default orders elements by the visual order (top-down, left-right) rather then the order in the AXChildren array. For example in this case, the bottom status bar of the document window gets separated from the bottom toolbar of the file browser, unlike the situation before grouping when both bars were adjacent to the VoiceOver user. --- Frameworks/OakTextView/src/OakDocumentView.mm | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Frameworks/OakTextView/src/OakDocumentView.mm b/Frameworks/OakTextView/src/OakDocumentView.mm index 7560d1d5..8482ec31 100644 --- a/Frameworks/OakTextView/src/OakDocumentView.mm +++ b/Frameworks/OakTextView/src/OakDocumentView.mm @@ -814,4 +814,38 @@ static std::string const kBookmarkType = "bookmark"; document->buffer().remove_all_marks(kBookmarkType); [[NSNotificationCenter defaultCenter] postNotificationName:GVColumnDataSourceDidChange object:self]; } + +// ================= +// = Accessibility = +// ================= + +- (BOOL)accessibilityIsIgnored +{ + return NO; +} + +- (NSArray*)accessibilityAttributeNames +{ + static NSArray* attributes = nil; + if(!attributes) + { + NSSet* set = [NSSet setWithArray:[super accessibilityAttributeNames]]; + set = [set setByAddingObjectsFromArray:@[ + NSAccessibilityRoleAttribute, + NSAccessibilityDescriptionAttribute, + ]]; + attributes = [set allObjects]; + } + return attributes; +} + +- (id)accessibilityAttributeValue:(NSString*)attribute +{ + if([attribute isEqualToString:NSAccessibilityRoleAttribute]) + return NSAccessibilityGroupRole; + else if([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) + return @"Editor"; + else + return [super accessibilityAttributeValue:attribute]; +} @end