I am trying to understand the correct use of the new NSAccessibility Protocol in Yosemite, with particular reference to the accessibilityTitleUIElement and accessibilityServesAsTitleForUIElements properties. I can make them work when I set them in code, but not when I connect accessibilityTitleUIElement in Interface Builder.
In my assistive application built and running under Yosemite DP8, the following code in -awakeFromNib works correctly:
[[self myTitleTextField] setAccessibilityServesAsTitleForUIElements:[NSArray arrayWithObjects:[self myRadioCluster], NULL]]; NSLog(@"serves as title UI element for radio cluster: %@", [[self myTitleTextField] accessibilityServesAsTitleForUIElements] ? @"YES" : @"NO"); [[self myRadioCluster] setAccessibilityTitleUIElement:[self myTitleTextField]]; NSLog(@"title UI element: %@", [[self myRadioCluster] accessibilityTitleUIElement]);
The log entries generated by this code are:
2014-09-29 11:38:20.291 UI Browser[3430:1226269] serves as title UI element for radio cluster: YES 2014-09-29 11:38:20.292 UI Browser[3430:1226269] title UI element: <NSTextField: 0x608000184780>
However, if I comment out the two setter calls and instead connect the “title” Accessibility connection in Interface Builder, neither attribute works. The Log entries are:
2014-09-29 11:50:27.046 UI Browser[3998:1231603] serves as title UI element for radio cluster: NO 2014-09-29 11:50:27.046 UI Browser[3998:1231603] title UI element: (null)
Am I doing something wrong, or am I just getting ahead of Yosemite and Interface Builder?
A related question:
I am aware that in the past the “AXServesAsTitleForUIElements” attribute had to be set in code instead of in Interface Builder. Is that still true, or does Yosemite’s improved ability to “infer” accessibility relationships mean that both attributes are supposed to be set in Interface Builder when I set the “title” Accessibility connection?
|