On 11 Jan 2009, at 10:34 PM, Yi Qiang wrote: Hi, I am trying to enable accessibility in my app and need a bit of help figuring out how to do it in IB. Specifically, I want to relate a label and a text field, e.g "Server: <server address>". The Accessibility Programming Guideline For Cocoa (url) states: "To do this, you create an accessibility object to represent the static text object. Then, in each accessibility object representing one of the titled user interface elements (each of the address fields, in this example), you add the NSAccessibilityTitleUIElementAttribute attribute. The value of this attribute is the accessibility object representing the static text title. Finally, in the static text title accessibility object, add the NSAccessibilityServesAsTitleForUIElementsAttribute attribute. The value of this attribute is an array of the accessibility objects for which this static text object serves as title (in this example, the array comprises the set of editable text fields)." In the information tab in the inspector,
I assume you mean the "Connection" tab. there are two things that look of interest to me. The "link" connection in particular looks relevant here. There are two headings I am interested in: "Accessibility" and "Accessibility Reference" 1. What is the difference between the two?
As I understand it, "Accessibility Reference" is the inverse of "Accessibility". You can also see that when you create a connection, because it will automatically create a connection in the opposite direction under the other heading.
It seems to me that the "title" under "Accessibility" represents the NSAccessibilityTitleUIElementAttribute and the "title" under "Accessibility Reference" represents the NSAccessibilityServesAsTitleForUIElementAttribute. Though I am a bit confused, as both connections can actually be multi-valued, while only NSAccessibilityServesAsTitleForUIElementAttribute is an NSArray. This may be a bug.
As for "link", that should represent the NSAccessibilityLinkedUIElementsAttribute under both headings. For "link" one the two are really equivalent AFAIK. Also note that this connection can be multi-valued (you can make several "link" connections from the same view), which is because this attribute is really an NSArray.
I do agree with you that the UI in IB is very confusing, especially in the popup menu, where you cannot even see the difference between the two. And the documentation far insufficient.
2. If I want to set a link between a label and a text field, do I link the text field to the label, or vice a versa? An do I do it in "Accessibility" or "Accessibility Reference"
You connect the "title" under "Accessibility" of the text field to the label. Remember that you want to represents the label as the NSAccessibilityTitleUIElementAttribute of the text field, while the text field should be the NSAccessibilityServesAsTitleForUIElementAttribute for the label. 3. Am I completely wrong about what the "link" reference is for?
I think so, if what you're saying that you thought to connect the "link" rather than the "title". So to be clear, for the connection between the text field and the label, you should use the "title", not the "link". The "link" is used for the NSAccessibilityLinkedUIElementsAttribute. You use it for associated accessible elements, e.g. a text field and an associated button, or two text fields (e.g. one for the hour and one for the minutes of a time).
Christiaan Cheers, Yi
|