Re: Position of "slide-in on hover" views and VoiceOver
Re: Position of "slide-in on hover" views and VoiceOver
- Subject: Re: Position of "slide-in on hover" views and VoiceOver
- From: Nick Kocharhook <email@hidden>
- Date: Thu, 01 May 2014 11:18:08 +0000
- Thread-topic: Position of "slide-in on hover" views and VoiceOver
On Apr 29, 2014, at 1:14 AM, Josh Scotland <email@hidden> wrote:
> What happens if you modify the AXPosition for these controls so that they return a position that you would like?
I tried using accessibilitySetOverrideValue:, but the problem (I think) is that my override value was getting cleared during the animation. So I never got to see the shifted position. More on this in my first message.
Anyway, I finally broke down and added subclasses for NSButton and NSTextField to do what I needed. It works great, although it's a bit annoying to need to subclass to get this behavior. Anyway, here's the code so the next person will know what works.
If I'm missing something, I'd love to hear about it! :-)
// ABCAccessibleTextField.h
@interface ABCAccessibleTextField : NSTextField
{
NSPoint accessibilityPositionOffset;
}
@property (nonatomic, assign) NSPoint accessibilityPositionOffset;
@end
// ABCAccessibleTextField.m
#import "ABCAccessibleTextField.h"
@implementation ABCAccessibleTextField
@synthesize accessibilityPositionOffset;
- (id)accessibilityAttributeValue:(NSString *)attribute
{
id value = nil;
// Position
if ([attribute isEqualToString:NSAccessibilityPositionAttribute])
{
NSPoint origin = [(NSValue *)[super accessibilityAttributeValue:attribute] pointValue];
if (!NSEqualPoints(NSZeroPoint, accessibilityPositionOffset))
{
origin.x += accessibilityPositionOffset.x;
origin.y += accessibilityPositionOffset.y;
}
value = [NSValue valueWithPoint:origin];
}
else
{
value = [super accessibilityAttributeValue:attribute];
}
return value;
}
@end
// In the NSViewController subclass which owns the controls. All controls inherit from one of the
// Accessible classes like above. Annoyingly, there needs to be on per NSControl subclass you
// want to do this with.
- (void)setShouldOffsetControls:(BOOL)shouldOffsetControls
{
NSPoint offset = NSZeroPoint;
NSArray *controls = @[button1, button2, textField1, textField2];
if (shouldOffsetControls) {
offset = NSMakePoint(0, -NSHeight(self.view.frame));
}
for (id control in controls) {
control.accessibilityPositionOffset = offset;
}
}
_______________________________________________
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