AX callback not getting called...
AX callback not getting called...
- Subject: AX callback not getting called...
- From: "charlie" <email@hidden>
- Date: Wed, 09 Jun 2010 05:36:55 +0000
AX callback not getting called. I read all the docs, searched google
extensively, read thru the few posts I could find that referenced
kAXFocusedUIElementChangedNotification, but nothing I found has worked.
To make sure it wasn't something strange about my app, I created a
fresh Cocoa application project, opened the nib and put a few text
fields in it and set each of their -nextKeyView's to make a tab-loop
around the whole set. Saved, then added the following code (copied
from my actual main project)...
(note: this is on 10.6.3, linking against the 10.5 SDK)
///////////////////
// .H
#import <Cocoa/Cocoa.h>
@interface helloAppDelegate : NSObject <NSApplicationDelegate>
{
}
@end
///////////////////
// .M
#import "helloAppDelegate.h"
@implementation helloAppDelegate
static void XXXControlFocusChanged(AXObserverRef observer,
AXUIElementRef element, CFStringRef notification, void * refcon)
{
NSLog(@"CALLBACK TRIGGERED");
}
- (void)registerForAXControlFocusChangedNotifications
{
pid_t pid = getpid();
AXUIElementRef appelement = AXUIElementCreateApplication(pid);
if (appelement)
{
AXObserverRef observer = nil;
if ( ( AXObserverCreate(pid, XXXControlFocusChanged, &observer) ==
kAXErrorSuccess ) && observer )
{
CFRunLoopAddSource(CFRunLoopGetCurrent(),
AXObserverGetRunLoopSource(observer), kCFRunLoopCommonModes);
if ( AXObserverAddNotification(observer, appelement,
kAXFocusedUIElementChangedNotification, self) == kAXErrorSuccess )
{
NSLog(@"SETUP COMPLETE");
}
CFRelease(observer);
}
CFRelease(appelement);
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSLog(@"APPLICATION LAUNCHED");
[self registerForAXControlFocusChangedNotifications];
}
@end
The output is always:
2010-06-08 23:24:35.146 hello[7983:a0f] APPLICATION LAUNCHED
2010-06-08 23:24:35.151 hello[7983:a0f] SETUP COMPLETE
No matter what I do, how I change focus, how the accessibility prefs
are setup... the callback is never triggered.
Anyone see why?
Thanks.
Chuck
_______________________________________________
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