NULL elements resolved
NULL elements resolved
- Subject: NULL elements resolved
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 22 Nov 2002 06:41:32 -0500
It has finally dawned on me that I am receiving NULL affected elements in
response to the AXUIElementDestroyed notification because -- well, the
element was destroyed. <Sounds of head banging against wall.> The observed
element is also NULL at callback time, for the same reason.
In other words, the documentation isn't quite accurate when it says "The
returned UIElement is no longer valid in the target application. You can
still use the local reference with calls like CFEqual (for example, to
remove it from a list), but you should not pass it to the accessibility
APIs."
In fact, there is no "returned UIElement" in the callback function in
response to an AXUIElementDestroyedNotification. I took this passage to mean
that I would receive a reference to the affected element in my callback, but
that I would have to be careful how I used it. In fact, I must cache the
observed element at the time when I register it for the
AXUIElementDestroyedNotification, if I want to make use of it as a "local
reference" at callback time, because by callback time it has turned into a
NULL element.
Is this a bug? If not, the documentation needs to be revised.
The argument for thinking of this as a design feature, not a bug, is that
receiving a NULL UIElement is safer than receiving an invalid UIElement.
Either way, any use of the invalid reference in other accessibility
functions should generate a kAXErrorInvalidUIElement error, but I suspect it
may more often be useful to be able to test the affected element for NULL
before using it in another function.
The argument for thinking of this as a bug is that it would be easier to get
the reference in the callback function, so it is available for use as a
"local reference" without having to cache it at registration time. But then
I would have to build the awareness that the UIElement has been destroyed
into my program logic, or deliberately do something to generate a
kAXErrorInvalidUIElement error.
So I vote for treating it as a feature.
--
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
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
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.