Re: Custom table cells
Re: Custom table cells
- Subject: Re: Custom table cells
- From: Mike Engber <email@hidden>
- Date: Wed, 3 Jun 2009 08:57:30 -0700
I can't tell you why Voice Over isn't using your value attribute, but
I have some general comments on your code (mainly that there should be
much less of it):
- You should not be overriding the role-description. Standard roles
have standard descriptions which describe the generic thing the role
represents and _not_ the particular instance they. E.g. "button", not
"cancel button".
Simply _not_ implementing NSAccessibilityRoleDescriptionAttribute is
normally the right thing to. The standard role description will be
returned for you. For cases where you are accessorizing from scratch
(e.g. a pure NSObject) we provide the function
NSAccessibilityRoleDescription to get those standard descriptions.
Summary - you should not be creating role descriptions.
- I think what you really want to do is override
NSAccessibilityDescriptionAttribute. "Timeline Tweet" is probably
appropriate for that.
- Since your class inherits from NSCell, you shouldn't have to
override NSAccessibilityRoleAttribute either.
- For the NSAccessibilityValueAttribute I don't see why you're not
using the controlView method to get the parentTableView. It is more
efficient and correct. You know the cell's controlView being is an
SRXTimelineTableView. In general, it's possible that a cell's
NSAccessibilityParentAttribute is not it's controlView.
Also, I would have guessed that since you subclassed cell, the tweet
would be the represented object of your custom cell - obviating the
need to access the table view.
- There should be no need to override accessibilityIsIgnored - you
should inherit that from NSTextCell.
- You also inherit accessibilityAttributeNames from NSTextCell. For
what you're doing there's no need to override it at all. If you follow
my advice and implement NSAccessibilityDescriptionAttribute, you
should call super, make a mutable copy, and add in
NSAccessibilityDescriptionAttribute.
-ME
---
- (BOOL)accessibilityIsIgnored {
return NO;
}
- (NSArray *)accessibilityAttributeNames {
if(validAXAttributes == nil) {
validAXAttributes = [[NSArray alloc]
initWithObjects:NSAccessibilityRoleAttribute,
NSAccessibilityRoleDescriptionAttribute,
NSAccessibilityHelpAttribute,
NSAccessibilityValueAttribute,
NSAccessibilityEnabledAttribute,
NSAccessibilityFocusedAttribute,
NSAccessibilityParentAttribute,
NSAccessibilityWindowAttribute,
NSAccessibilityTopLevelUIElementAttribute,
NSAccessibilityPositionAttribute,
NSAccessibilitySizeAttribute, nil];
}
return validAXAttributes;
}
- (id)accessibilityAttributeValue:(NSString *)attribute
{
if([attribute isEqualToString:NSAccessibilityRoleAttribute]) //AXRole
return NSAccessibilityStaticTextRole;
if([attribute
isEqualToString:NSAccessibilityRoleDescriptionAttribute]) //
AXRoleDescription
return @"Timeline Tweet";
if([attribute isEqualToString:NSAccessibilityHelpAttribute]) //AXHelp
return @"Timeline Tweet";
if([attribute isEqualToString:NSAccessibilityValueAttribute]) { //
AXValue
SRXTimelineTableView* parentTableView = [super
accessibilityAttributeValue:NSAccessibilityParentAttribute];
SRXTweetObject* tweet = [parentTableView tweetForSelectedRow];
return [NSString stringWithFormat:@"%@: %@",[tweet.user
displayName], tweet.text];
}
return [super accessibilityAttributeValue:attribute];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden