Re: sample code for notifications?
Re: sample code for notifications?
- Subject: Re: sample code for notifications?
- From: Ken Ferry <email@hidden>
- Date: Sat, 12 Jul 2003 16:58:17 -0400
Feel free to post your code snippet that is not working.
Well, since you make it so easy.. :)
I'm actually trying to register for notifications in a cocoa app -
probably should have said that in the first place. At the bottom of
the awakeFromNib method in my subclass of NSWindowController I have
this:
AXError err;
AXUIElementRef sendingApp = AXUIElementCreateApplication (sendingAppPid);
AXObserverRef observer;
err = AXObserverCreate (myPid, callback, &observer);
err = AXObserverAddNotification (observer, sendingApp,
kAXWindowCreatedNotification, nil);
CFRunLoopAddSource ([[NSRunLoop currentRunLoop] getCFRunLoop],
AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode);
Above the implementation of the class I have
static void callback (AXObserverRef observer, AXUIElementRef element,
CFStringRef notification, void *refcon)
{
NSLog(@"Received notification: %@", (NSString *)notification);
}
Finally, in the corresponding .h file, above the interface section, I have
static void callback (AXObserverRef observer, AXUIElementRef element,
CFStringRef notification, void *refcon);
Now I do have a real error reported though, which is probably a good
thing: The call to AXObserverAddNotification returns a
kAXErrorIllegalArgument error. Unfortunately I still can't see
what's wrong with the call. I've verified in the debugger that
sendingApp and callback are correct (sendingApp responds properly to
queries for attribute values). I don't know how to directly verify
that observer is what it's supposed to be, but the call to
AXObserverCreate returns AXErrorSuccess. I've tried perturbations
such as adding the notification after calling CFRunLoopAddSource - no
difference.
Any thoughts are appreciated,
Ken
_______________________________________________
accessibility-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/accessibility-dev
Do not post admin requests to the list. They will be ignored.