Re: Setting AXDescription from a nib
Re: Setting AXDescription from a nib
- Subject: Re: Setting AXDescription from a nib
- From: Avi Drissman <email@hidden>
- Date: Wed, 23 Dec 2009 10:05:28 -0500
That sounds like the element would need to be on-screen. That's a problem, as this would be happening at nib-loading time (this is a view being extracted from a nib) before it's displayed on-screen.
It sounds like I'm SOL. :(
Avi
On Wed, Dec 23, 2009 at 8:46 AM, Martin Pilkington
<email@hidden> wrote:
Hi Avi,
It sounds like you probably need the C Accessibility API. You'll probably want to do something like this (note I haven't compiled this so there may be bugs):
CGFloat x = //get the x co-ordinate of the UI element from the left of the screen
CGFloat y = //get the y co-ordinate of the UI element from the top of the screen
AXUIElementRef element;
AXError error = AXUIElementCopyElementAtPosition(AXUIElementCreateSystemWide(), x, y, &element);
if (error == kAXErrorSuccess) {
CFTypeRef value;
error = AXUIElementCopyAttributeValue(element, kAXDescriptionAttribute, &value);
if (error == kAXErrorSuccess) {
NSString *description = (NSString *)value;
}
}
For more information, if you search for accessibility in the Xcode documentation window, the top result in the title search is usually "Accessibility (ApplicationServices/HIServices) Reference" which is the API reference for the Accessibility APIs.
Martin
On 23 Dec 2009, at 5:15 am, Avi Drissman wrote:
OK, but I need to know the old value. It's a token that I run through my strings table to get the new value to set (so we only need one nib). If I can't retrieve the value I'm really stuck.
Avi
On Tue, Dec 22, 2009 at 6:41 PM, Mike Engber
<email@hidden> wrote:
On Dec 22, 2009, at 1:44 PM, Avi Drissman wrote:
Ugh. But if I mouse over it, Accessibility Inspector shows me the value I set from the nib and can't access from the code.
Where does that value live? How can I get at it from the code? I feel like I'm missing something fundamental here.
IB is using:
- (BOOL)accessibilitySetOverrideValue:(id)value forAttribute:(NSString *)attribute;
Attributes created/modified this way are sort of snuck in and are only available through the AX calls - i.e. the API used by assistive apps.
If you need to modify the value programatically, you can call accessibilitySetOverrideValue.
-ME
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
This email sent to email@hidden
_______________________________________________
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