forked from twitter-archive/twui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split out all the TUINSView accessibility into its own category
- Loading branch information
Showing
4 changed files
with
166 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// TUINSView+Accessibility.h | ||
// TwUI | ||
// | ||
// Created by Josh Abernathy on 7/28/11. | ||
// Copyright 2011 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "TUINSView.h" | ||
|
||
|
||
@interface TUINSView (Accessibility) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// | ||
// TUINSView+Accessibility.m | ||
// TwUI | ||
// | ||
// Created by Josh Abernathy on 7/28/11. | ||
// Copyright 2011 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "TUINSView+Accessibility.h" | ||
#import "TUIView+Accessibility.h" | ||
|
||
|
||
@implementation TUINSView (Accessibility) | ||
|
||
//- (id)accessibilityHitTest:(NSPoint)point | ||
//{ | ||
// NSPoint windowPoint = [[self window] convertScreenToBase:point]; | ||
// NSPoint localPoint = [self convertPoint:windowPoint fromView:nil]; | ||
// return [rootView accessibilityHitTest:localPoint]; | ||
//} | ||
|
||
- (BOOL)accessibilityIsIgnored | ||
{ | ||
return NO; | ||
} | ||
// | ||
//- (id)accessibilityAttributeValue:(NSString *)attribute | ||
//{ | ||
// if([attribute isEqualToString:NSAccessibilityRoleAttribute]) { | ||
// return NSAccessibilityGroupRole; | ||
// } else if([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) { | ||
// return NSAccessibilityRoleDescriptionForUIElement(self); | ||
// } else if([attribute isEqualToString:NSAccessibilityChildrenAttribute]) { | ||
// return [self.rootView accessibleSubviews]; | ||
// } else { | ||
// return [super accessibilityAttributeValue:attribute]; | ||
// } | ||
//} | ||
|
||
- (id)accessibilityHitTest:(NSPoint)point | ||
{ | ||
return self; | ||
} | ||
|
||
- (NSArray *)accessibilityAttributeNames | ||
{ | ||
static NSArray *attributes = nil; | ||
if(attributes == nil) { | ||
attributes = [[NSArray alloc] initWithObjects:NSAccessibilityRoleAttribute, NSAccessibilityRoleDescriptionAttribute, NSAccessibilityFocusedAttribute, NSAccessibilityParentAttribute, NSAccessibilityWindowAttribute, NSAccessibilityTopLevelUIElementAttribute, NSAccessibilityPositionAttribute, NSAccessibilitySizeAttribute, nil]; | ||
} | ||
|
||
return attributes; | ||
} | ||
|
||
- (id)accessibilityAttributeValue:(NSString *)attribute | ||
{ | ||
if([attribute isEqualToString:NSAccessibilityRoleAttribute]) { | ||
return NSAccessibilityGroupRole; | ||
} else if([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) { | ||
return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, nil); | ||
} else if([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | ||
// Just check if the app thinks we're focused. | ||
id focusedElement = [NSApp accessibilityAttributeValue:NSAccessibilityFocusedUIElementAttribute]; | ||
return [NSNumber numberWithBool:[focusedElement isEqual:self]]; | ||
} else if([attribute isEqualToString:NSAccessibilityParentAttribute]) { | ||
return NSAccessibilityUnignoredAncestor(self.superview); | ||
} else if([attribute isEqualToString:NSAccessibilityWindowAttribute]) { | ||
// We're in the same window as our parent. | ||
return [self.superview accessibilityAttributeValue:NSAccessibilityWindowAttribute]; | ||
} else if([attribute isEqualToString:NSAccessibilityTopLevelUIElementAttribute]) { | ||
// We're in the same top level element as our parent. | ||
return [self.superview accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute]; | ||
} else if([attribute isEqualToString:NSAccessibilityPositionAttribute]) { | ||
return [NSValue valueWithPoint:[[self window] convertBaseToScreen:[self convertPoint:self.bounds.origin toView:nil]]]; | ||
|
||
} else if([attribute isEqualToString:NSAccessibilitySizeAttribute]) { | ||
return [NSValue valueWithSize:self.bounds.size]; | ||
} else { | ||
return nil; | ||
} | ||
} | ||
|
||
- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute | ||
{ | ||
if([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | ||
return NO; //[parent isFauxUIElementFocusable:self]; | ||
} else { | ||
return NO; | ||
} | ||
} | ||
|
||
- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute | ||
{ | ||
if([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | ||
// [parent fauxUIElement:self setFocus:value]; | ||
} | ||
} | ||
|
||
- (NSArray *)accessibilityActionNames | ||
{ | ||
return [NSArray array]; | ||
} | ||
|
||
- (NSString *)accessibilityActionDescription:(NSString *)action | ||
{ | ||
return nil; | ||
} | ||
|
||
- (void)accessibilityPerformAction:(NSString *)action | ||
{ | ||
|
||
} | ||
|
||
- (id)accessibilityFocusedUIElement | ||
{ | ||
return NSAccessibilityUnignoredAncestor(self); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters