Re: sample code for notifications?
Re: sample code for notifications?
- Subject: Re: sample code for notifications?
- From: John Louch <email@hidden>
- Date: Sat, 12 Jul 2003 14:09:29 -0700
The element you pass to AXObserverAddNotification must have the same pid as
the one you use to create the observer.
I am assuming that sendingAppPid != myPid.
Thanks,
jl
>
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.
---------------------------------------------
John Louch Internet #: email@hidden
(805) 546 0216
_______________________________________________
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.