If you look into the
AXNotificationConstants.h header file carefully, you may find that the
definition of kAXTitleChangedNotification has a significant different pattern
from its neighbors, for example:
#define
kAXMovedNotification CFSTR("AXMoved")
#define
kAXSelectedTextChangedNotification CFSTR("AXSelectedTextChanged")
#define
kAXTitleChangedNotification CFSTR("AXTitleChangedNotification")
So, try to replace
kAXTitleChangedNotification with CFSTR("AXTitleChanged") in your code,
and see if it works.
Chen
From:
accessibility-dev-bounces+chen.wang=email@hidden
[mailto:accessibility-dev-bounces+chen.wang=email@hidden] On Behalf Of Paul Godavari
Sent: Tuesday, July 27, 2010 10:01
PM
To: Bill Cheeseman
Cc: Accessibility-Dev Mail Mail
Subject: Re: Detecting window
title changes and kAXTitleChangeNotification
Hi Bill, thanks for the reply.
I took a look at UI Browser and it does indeed notice window title
changes on all the applications I tested. However, I'm still unable to get
those notifications in my own application. I created a very simple Cocoa application to demonstrate the problem, listed
below. From this app, I receive create, move and destroy notifications, but not
the title changes. In my testing the app, I do not get any errors from any of
the API calls.
Do you see any issues
with my notification registrations?
@implementation
AccessibilityAppDelegate
// Accessibility notification callback.
void AXCallback(AXObserverRef observer, AXUIElementRef element,
CFStringRef
notificationName, void* contextData)
{
NSLog(@"Notification: %@", (NSString*)
notificationName);
}
// Register to receive notifications for the process 'pid'.
- (void) registerProcess:(int)pid withName:(NSString*)name
{
NSLog(@"Registering application %@", name);
AXUIElementRef process =
AXUIElementCreateApplication(pid);
AXObserverRef observer;
AXObserverCreate(pid, AXCallback, &observer);
AXObserverAddNotification(observer, process,
kAXWindowCreatedNotification, self);
AXObserverAddNotification(observer, process,
kAXUIElementDestroyedNotification, self);
AXObserverAddNotification(observer, process,
kAXWindowMovedNotification, self);
AXObserverAddNotification(observer, process,
kAXTitleChangedNotification, self);
CFRunLoopAddSource(CFRunLoopGetCurrent(),
AXObserverGetRunLoopSource(observer),
kCFRunLoopDefaultMode);
}
// Register for notifications on all running processes.
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSArray* launchedApps = [[NSWorkspace sharedWorkspace]
launchedApplications];
for (NSDictionary* dictionary in launchedApps) {
NSString* name = [dictionary
objectForKey:@"NSApplicationName"];
int pid = [[dictionary
objectForKey:@"NSApplicationProcessIdentifier"] intValue];
[self registerProcess:pid withName:name];
}
}
@end
On Tue, Jul 27, 2010 at 3:20 PM, Bill Cheeseman <email@hidden> wrote:
On Jul 27, 2010, at 5:44 PM, Paul Godavari wrote:
I have been able to detect
window create, move and destroy operations, but not title change notifications.
I've been trying to detect title changes by registering an AXObserver callback
on the AXUIElementRef representing the window using the
kAXTitleChangeNotification, but no notifications ever arrive for the observed
windows.
That's the right way to do it, and it works for me. I run my UI Browser
application and use its Notifications drawer to register a title changed
notification on an Untitled TextEdit window. Then I save the TextEdit document
to a name, and as soon as it's saved, the UI Browser Notifications Log window
shows the title changed notification. <http://pfiddlesoft.com/uibrowser/>
_______________________________________________
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
Confidentiality Notice:
E-mail may be intercepted between the sender and the receiver and is
therefore neither secure nor confidential. Your continued use of e-mail
communication confirms that you accept this risk. If this is an urgent
matter, please contact me at the phone number provided. This e-mail,
including any attachments, is for the sole use of the intended recipient(s)
and may contain private, confidential, and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited. If you
are not the intended recipient or this information has been
inappropriately forwarded to you, please contact the sender by reply
e-mail and destroy all copies of the original.
|