Skip to content
Snippets Groups Projects
Commit 57060bad authored by George Nachman's avatar George Nachman
Browse files

Try to use the new OS 10.10 accessibility APIs to make tab bar cells...

Try to use the new OS 10.10 accessibility APIs to make tab bar cells accessible. For some reason they are not selectable by accessibility.
parent 62160fb4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -50,6 +50,8 @@
@property(nonatomic, readonly) float desiredWidthOfCell;
@property(nonatomic, readonly) id<PSMTabStyle> style;
@property(nonatomic, assign) NSLineBreakMode truncationStyle; // How to truncate title.
@property(nonatomic, readonly) BOOL isSelected;
@property(nonatomic, readonly) NSAccessibilityElement<NSAccessibilityRadioButton> *element;
 
// creation/destruction
- (id)initWithControlView:(PSMTabBarControl *)controlView;
Loading
Loading
Loading
Loading
@@ -12,6 +12,52 @@
#import "PSMProgressIndicator.h"
#import "PSMTabDragAssistant.h"
 
@interface PSMTabBarCell()<PSMProgressIndicatorDelegate>
- (NSView<PSMTabBarControlProtocol> *)psmTabControlView;
@end
@interface PSMTabBarControlAccessibilityElement : NSAccessibilityElement<NSAccessibilityRadioButton>
@property(nonatomic, assign) PSMTabBarCell *cell;
- (instancetype)initWithCell:(PSMTabBarCell *)cell;
@end
@implementation PSMTabBarControlAccessibilityElement
- (instancetype)initWithCell:(PSMTabBarCell *)cell {
self = [super init];
if (self) {
self.accessibilityRole = NSAccessibilityRadioButtonRole;
self.accessibilityLabel = @"Tab";
self.accessibilityParent = cell;
self.accessibilityEnabled = YES;
self.cell = cell;
}
return self;
}
- (id)accessibilityValue {
return @(self.cell.isSelected);
}
- (NSString *)accessibilityLabel {
return @"Tab";
}
- (BOOL)accessibilityPerformPress {
return NO;
}
- (NSRect)accessibilityFrame {
return self.cell.frame;
}
- (id)accessibilityParent {
return self.cell.psmTabControlView;
}
@end
// A timer that does not keep a strong reference to its target. The target
// should invoke -invalidate from its -dealloc method and release the timer to
// avoid getting called posthumously.
Loading
Loading
@@ -64,9 +110,6 @@
 
@end
 
@interface PSMTabBarCell()<PSMProgressIndicatorDelegate>
@end
@implementation PSMTabBarCell {
NSSize _stringSize;
PSMProgressIndicator *_indicator;
Loading
Loading
@@ -74,6 +117,7 @@
PSMWeakTimer *_delayedStringValueTimer; // For bug 3957
BOOL _hasIcon;
BOOL _highlighted;
PSMTabBarControlAccessibilityElement *_element;
}
 
#pragma mark - Creation/Destruction
Loading
Loading
@@ -91,6 +135,7 @@
_hasCloseButton = YES;
_modifierString = [@"" copy];
_truncationStyle = NSLineBreakByTruncatingTail;
_element = [[PSMTabBarControlAccessibilityElement alloc] initWithCell:self];
}
return self;
}
Loading
Loading
@@ -125,6 +170,8 @@
} else {
[self setCurrentStep:0];
}
_element = [[PSMTabBarControlAccessibilityElement alloc] initWithCell:self];
_element.cell = self;
}
return self;
}
Loading
Loading
@@ -139,6 +186,8 @@
if (_tabColor) {
[_tabColor release];
}
_element.cell = nil;
[_element release];
[super dealloc];
}
 
Loading
Loading
@@ -387,6 +436,10 @@
return self;
}
 
- (BOOL)isSelected {
return ([self tabState] == PSMTab_SelectedMask);
}
#pragma mark - Accessibility
 
- (BOOL)accessibilityIsIgnored {
Loading
Loading
@@ -433,7 +486,7 @@
} else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) {
attributeValue = [self stringValue];
} else if ([attribute isEqualToString: NSAccessibilityValueAttribute]) {
attributeValue = [NSNumber numberWithBool:([self tabState] == 2)];
attributeValue = @(self.isSelected);
} else {
attributeValue = [super accessibilityAttributeValue:attribute];
}
Loading
Loading
Loading
Loading
@@ -1739,6 +1739,13 @@ const NSInteger kPSMStartResizeAnimation = 0;
if ([[self delegate] respondsToSelector:@selector(tabViewDidChangeNumberOfTabViewItems:)]) {
[[self delegate] tabViewDidChangeNumberOfTabViewItems:aTabView];
}
NSMutableArray *elements = [NSMutableArray array];
for (PSMTabBarCell *cell in [_cells subarrayWithRange:NSMakeRange(0, self.numberOfVisibleTabs)]) {
[elements addObject:cell.element];
cell.element.accessibilityFrameInParentSpace = cell.frame;
}
[self setAccessibilityChildren:elements];
}
 
- (NSDragOperation)tabView:(NSTabView *)tabView draggingEnteredTabBarForSender:(id<NSDraggingInfo>)tagViewItem {
Loading
Loading
@@ -1992,7 +1999,11 @@ const NSInteger kPSMStartResizeAnimation = 0;
if (![_addTabButton isHidden]) {
[children addObject:_addTabButton];
}
attributeValue = NSAccessibilityUnignoredChildren(children);
NSMutableArray *elements = [NSMutableArray array];
for (PSMTabBarCell *cell in children) {
[elements addObject:cell.element];
}
attributeValue = elements;
} else if ([attribute isEqualToString: NSAccessibilityTabsAttribute]) {
attributeValue = NSAccessibilityUnignoredChildren(_cells);
} else if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment