Skip to content

Commit

Permalink
split out all the TUINSView accessibility into its own category
Browse files Browse the repository at this point in the history
  • Loading branch information
joshaber committed Aug 2, 2011
1 parent d75decb commit 2ffaac9
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 102 deletions.
32 changes: 32 additions & 0 deletions TwUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
5EE983EA13BE7834005F430D /* TUIViewNSViewContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C9013BE6E1900C85CB5 /* TUIViewNSViewContainer.m */; };
5EE983EB13BE783A005F430D /* ABActiveRange.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C3A13BE6E1900C85CB5 /* ABActiveRange.m */; };
5EE983EC13BE783A005F430D /* CoreText+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C3C13BE6E1900C85CB5 /* CoreText+Additions.m */; };
8819794413E26E0200AA39EB /* TUIView+Accessibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 8819794213E26E0200AA39EB /* TUIView+Accessibility.h */; };
8819794513E26E0200AA39EB /* TUIView+Accessibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 8819794213E26E0200AA39EB /* TUIView+Accessibility.h */; };
8819794613E26E0200AA39EB /* TUIView+Accessibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 8819794213E26E0200AA39EB /* TUIView+Accessibility.h */; };
8819794713E26E0200AA39EB /* TUIView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 8819794313E26E0200AA39EB /* TUIView+Accessibility.m */; };
8819794813E26E0200AA39EB /* TUIView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 8819794313E26E0200AA39EB /* TUIView+Accessibility.m */; };
8819794913E26E0200AA39EB /* TUIView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 8819794313E26E0200AA39EB /* TUIView+Accessibility.m */; };
8819794C13E26E5800AA39EB /* TUINSView+Accessibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 8819794A13E26E5800AA39EB /* TUINSView+Accessibility.h */; };
8819794D13E26E5800AA39EB /* TUINSView+Accessibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 8819794A13E26E5800AA39EB /* TUINSView+Accessibility.h */; };
8819794E13E26E5800AA39EB /* TUINSView+Accessibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 8819794A13E26E5800AA39EB /* TUINSView+Accessibility.h */; };
8819794F13E26E5800AA39EB /* TUINSView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 8819794B13E26E5800AA39EB /* TUINSView+Accessibility.m */; };
8819795013E26E5800AA39EB /* TUINSView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 8819794B13E26E5800AA39EB /* TUINSView+Accessibility.m */; };
8819795113E26E5800AA39EB /* TUINSView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 8819794B13E26E5800AA39EB /* TUINSView+Accessibility.m */; };
886EBA7F13D64393006DE018 /* TUIControl+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 886EBA7D13D64393006DE018 /* TUIControl+Private.h */; };
886EBA8013D64393006DE018 /* TUIControl+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 886EBA7D13D64393006DE018 /* TUIControl+Private.h */; };
886EBA8113D64393006DE018 /* TUIControl+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 886EBA7D13D64393006DE018 /* TUIControl+Private.h */; };
Expand Down Expand Up @@ -224,6 +236,10 @@
/* Begin PBXFileReference section */
5EE9839C13BE7650005F430D /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
5EE983B713BE7809005F430D /* libtwui.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libtwui.a; sourceTree = BUILT_PRODUCTS_DIR; };
8819794213E26E0200AA39EB /* TUIView+Accessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIView+Accessibility.h"; sourceTree = "<group>"; };
8819794313E26E0200AA39EB /* TUIView+Accessibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIView+Accessibility.m"; sourceTree = "<group>"; };
8819794A13E26E5800AA39EB /* TUINSView+Accessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUINSView+Accessibility.h"; sourceTree = "<group>"; };
8819794B13E26E5800AA39EB /* TUINSView+Accessibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUINSView+Accessibility.m"; sourceTree = "<group>"; };
886EBA7D13D64393006DE018 /* TUIControl+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIControl+Private.h"; sourceTree = "<group>"; };
886EBA7E13D64393006DE018 /* TUIControl+Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIControl+Private.m"; sourceTree = "<group>"; };
CB5B264C13BE6DA200579B1E /* TwUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TwUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -519,6 +535,8 @@
CBB74C6013BE6E1900C85CB5 /* TUINSView+NSTextInputClient.m */,
CBB74C6113BE6E1900C85CB5 /* TUINSView.h */,
CBB74C6213BE6E1900C85CB5 /* TUINSView.m */,
8819794A13E26E5800AA39EB /* TUINSView+Accessibility.h */,
8819794B13E26E5800AA39EB /* TUINSView+Accessibility.m */,
CBB74C6313BE6E1900C85CB5 /* TUINSWindow.h */,
CBB74C6413BE6E1900C85CB5 /* TUINSWindow.m */,
CBB74C6513BE6E1900C85CB5 /* TUIResponder.h */,
Expand Down Expand Up @@ -550,6 +568,8 @@
CBB74C7F13BE6E1900C85CB5 /* TUITextView.m */,
CBB74C8013BE6E1900C85CB5 /* TUITooltipWindow.h */,
CBB74C8113BE6E1900C85CB5 /* TUITooltipWindow.m */,
8819794213E26E0200AA39EB /* TUIView+Accessibility.h */,
8819794313E26E0200AA39EB /* TUIView+Accessibility.m */,
CBB74C8213BE6E1900C85CB5 /* TUIView+Animation.m */,
CBB74C8313BE6E1900C85CB5 /* TUIView+Event.h */,
CBB74C8413BE6E1900C85CB5 /* TUIView+Event.m */,
Expand Down Expand Up @@ -578,6 +598,8 @@
buildActionMask = 2147483647;
files = (
886EBA8113D64393006DE018 /* TUIControl+Private.h in Headers */,
8819794613E26E0200AA39EB /* TUIView+Accessibility.h in Headers */,
8819794E13E26E5800AA39EB /* TUINSView+Accessibility.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -627,6 +649,8 @@
CBB74CE413BE6E1900C85CB5 /* TUIViewController.h in Headers */,
CBB74CE613BE6E1900C85CB5 /* TUIViewNSViewContainer.h in Headers */,
886EBA7F13D64393006DE018 /* TUIControl+Private.h in Headers */,
8819794413E26E0200AA39EB /* TUIView+Accessibility.h in Headers */,
8819794C13E26E5800AA39EB /* TUINSView+Accessibility.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -635,6 +659,8 @@
buildActionMask = 2147483647;
files = (
886EBA8013D64393006DE018 /* TUIControl+Private.h in Headers */,
8819794513E26E0200AA39EB /* TUIView+Accessibility.h in Headers */,
8819794D13E26E5800AA39EB /* TUINSView+Accessibility.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -828,6 +854,8 @@
5EE983E913BE7834005F430D /* TUIViewController.m in Sources */,
5EE983EA13BE7834005F430D /* TUIViewNSViewContainer.m in Sources */,
886EBA8413D64393006DE018 /* TUIControl+Private.m in Sources */,
8819794913E26E0200AA39EB /* TUIView+Accessibility.m in Sources */,
8819795113E26E5800AA39EB /* TUINSView+Accessibility.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -882,6 +910,8 @@
CBB74CE513BE6E1900C85CB5 /* TUIViewController.m in Sources */,
CBB74CE713BE6E1900C85CB5 /* TUIViewNSViewContainer.m in Sources */,
886EBA8213D64393006DE018 /* TUIControl+Private.m in Sources */,
8819794713E26E0200AA39EB /* TUIView+Accessibility.m in Sources */,
8819794F13E26E5800AA39EB /* TUINSView+Accessibility.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -945,6 +975,8 @@
CB5E326C13BE70CA004B7899 /* TUIViewController.m in Sources */,
CB5E326E13BE70CA004B7899 /* TUIViewNSViewContainer.m in Sources */,
886EBA8313D64393006DE018 /* TUIControl+Private.m in Sources */,
8819794813E26E0200AA39EB /* TUIView+Accessibility.m in Sources */,
8819795013E26E5800AA39EB /* TUINSView+Accessibility.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
15 changes: 15 additions & 0 deletions lib/UIKit/TUINSView+Accessibility.h
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
119 changes: 119 additions & 0 deletions lib/UIKit/TUINSView+Accessibility.m
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
102 changes: 0 additions & 102 deletions lib/UIKit/TUINSView.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#import "TUIView+Private.h"
#import "TUITextRenderer+Event.h"
#import "TUITooltipWindow.h"
#import "TUIView+Accessibility.h"
#import <CoreFoundation/CoreFoundation.h>

@implementation TUINSView
Expand Down Expand Up @@ -288,107 +287,6 @@ - (void)swipeWithEvent:(NSEvent *)event
}
}

//- (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 @"radioButton";
} else if([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
return @"radio button"; //NSAccessibilityRoleDescription(role, 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);
}

- (BOOL)performKeyEquivalent:(NSEvent *)event
{
return [rootView performKeyEquivalent:event];
Expand Down

0 comments on commit 2ffaac9

Please sign in to comment.