Accessibility in custom NSControl subclasses
Accessibility in custom NSControl subclasses
- Subject: Accessibility in custom NSControl subclasses
- From: Stephen Blinkhorn <email@hidden>
- Date: Sun, 27 Feb 2011 19:12:38 -0600
Hello,
I make extensive use of custom NSControls in some of my GUIs. Recently
I ran into a problem whilst trying to implement accessibility features
in these controls.
I have added the test methods below which work perfectly for custom
NSView classes but are not working as expected with custom NSControl
classes. With custom NSControl classes voice over reads out the
application name instead of value, role and description details.
Can anyone shed any light on why this is happening? Maybe it is worth
mentioning that none of my controls use NSCell classes at this time.
-(BOOL)accessibilityIsIgnored {
return NO;
}
-(NSArray*)accessibilityAttributeNames
{
NSArray* attributes = [super accessibilityAttributeNames];
NSMutableArray* mutable_attributes = [[NSMutableArray alloc]
initWithCapacity:[attributes count]];
[mutable_attributes addObjectsFromArray:attributes];
[mutable_attributes addObject:NSAccessibilityValueAttribute];
[mutable_attributes
addObject:NSAccessibilityValueDescriptionAttribute];
return (NSArray*)mutable_attributes;
}
-(id)accessibilityAttributeValue:(NSString *)attribute
{
if([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
return NSAccessibilitySliderRole;
} else if([attribute
isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
return NSAccessibilityRoleDescriptionForUIElement(self);
} else if([attribute isEqualToString:NSAccessibilityValueAttribute]) {
return [NSNumber numberWithFloat:50.0];
} else if([attribute
isEqualToString:NSAccessibilityValueDescriptionAttribute]) {
return @"50%";
} else {
return [super accessibilityAttributeValue:attribute];
};
}
Thanks,
Stephen
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden