Re: obtain AXUIElementRef from NSButton and multiple notifications
Re: obtain AXUIElementRef from NSButton and multiple notifications
- Subject: Re: obtain AXUIElementRef from NSButton and multiple notifications
- From: Bill Cheeseman <email@hidden>
- Date: Sat, 05 Jun 2004 06:34:07 -0400
on 2004-06-05 3:24 AM, Joji Mori at email@hidden wrote:
>
1. Can you obtain a AXUIElementRef from an object such as an NSButton.
>
I suspect this is not possible because UIElementRef's should be
>
obtained exclusively through the accessibility API. Is this the case?
As far as I know, Cocoa does not make any methods available for getting the
accessibility API object from a Cocoa UI element. But it is fairly easy to
do using the accessibility API.
>
2. A while back I remember the discussion about two notifications being
>
sent for the kAXApplicationActivatedNotification and also for
>
deactivation. I am finding it occurring with some applications but not
>
all. Is it true that this is a bug for the moment? Or is there a way to
>
stop it from happening?
This bug still exists as of Mac OS X 10.3.4. It only affects Cocoa
applications; you won't see it when you register for these notifications
from Carbon applications. Basically, as an Apple engineer explained it to
me, when Cocoa uses Carbon under the hood to implement a UI element, Carbon
doesn't realize that Cocoa is using it, and both Carbon and Cocoa issue the
same notification.
It is very difficult to work around this bug, so I'm surprised that Apple
hasn't fixed it yet. It's been known from the beginning of accessibility in
Mac OS X 10.2.0. I imagine that this bug has prevented a lot of people from
implementing accessibility notifications.
A workaround strategy is to test in the callback to see whether the same
notification was already just received, with no intervening notifications
received from other UI elements, and, if so, to ignore the second
notification. Doing this makes it unnecessary to figure out whether the
target is Carbon or Cocoa, which cannot be reliably or conveniently done, as
far as I know. I find that the logic of this workaround requires you to
automatically register both paired notifications when one is wanted, which
is a bit of a nuisance.
The hidden/shown notification pair is also affected by this bug.
You can see the workaround in action in my PreFab UI Browser, where
registering one of a pair in the Notifications drawer automatically
registers both, and in the Notification Log window where received
notifications are not doubled up. Unregistering one of the pair also
automatically unregisters the other. Go to www.prefab.com/uibrowser (free
30-day trial version).
I have written a very comprehensive and thoroughly documented Cocoa
framework for the entire accessibility API. It has served as the engine for
PreFab UI Browser for about two years now and is very well tested. It works
around this and many other known accessibility bugs, both in Jaguar and the
new bugs in Panther. We at PreFab are thinking about licensing it for a fair
price, one price for the binary-only form (deployment and debug versions)
and maybe one with source at a higher price. The only thing holding us back
is that we haven't figured out what a fair price would be -- certainly in
the hundreds of dollars for the binary (one license covers use in one client
product, flat fee up front, no further royalties for that client product;
but you need a second license for a second client product), and maybe in the
thousands if we decide to license source (which you would only need to
license once). We aren't interested in giving it away free or cheap, because
a very large amount of time went into creating and polishing it. Would there
be any interest among accessibility developers on these terms?
I will be at the Wednesday evening accessibility BoF at WWDC. I would like
to talk with accessibility developers about this.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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.