Re: Add accessibility for custom controls in a standard Carbon window
Re: Add accessibility for custom controls in a standard Carbon window
- Subject: Re: Add accessibility for custom controls in a standard Carbon window
- From: Eric Schlegel <email@hidden>
- Date: Fri, 02 Oct 2009 13:08:30 -0700
On Oct 1, 2009, at 5:15 PM, Xiang Cao wrote:
Thanks. That works great. I have another quick question. When they are
asking for attributes values, how should I return the value?
I tried to use this to respond a role attribute, but it does not
work. The
verifier says it cannot find the role.
Return ::SetEventParameter(iEvent,
kEventParamAccessibleAttributeValue,
typeCFStringRef, sizeof(CFStringRef), kAXButtonRole);
Is the type correct?
There's at least one obvious (and common) error here in this code: the
last parameter to SetEventParameter must be a pointer to the data to
be stored in the event, not the data itself. kAXButtonRole is a
CFStringRef constant, that is, the data itself. You need to pass a
pointer to the CFStringRef:
CFStringRef roleStr = kAXButtonRole;
SetEventParameter( iEvent, kEventParamAccessibleAttributeValue,
typeCFStringRef, sizeof( CFStringRef ), &roleStr );
I'm not certain that's the cause of the verifier error, but fix that
first and then see.
I wonder where can I find the correct CF Types to
respond for each attribute. For example, what kind of data should I
pass in
responding of position and size query?
The comments in AXAttributeConstants.h should identify the CF type to
use in each case:
/*
kAXPositionAttribute
The global screen position of the top-left corner of an element.
Value: An AXValueRef with type kAXValueCGPointType. 0,0 is the top-left
corner of the screen that displays the menu bar. The value of the
horizontal
axis increases to the right. The value of the vertical axis increases
downward. Units are pixels.
Writable? Generally no. However, some elements that can be moved by
the user
through direct manipulation (like windows) should offer a writable
position
attribute.
Required for all elements that are visible on the screen, which is
virtually
all elements.
*/
#define kAXPositionAttribute CFSTR("AXPosition")
So for position, you would use AXValueCreate from AXValue.h to create
an AXValueRef from a CGPoint, and then pass the address of the
AXValueRef to SetEventParameter. Although actually, for various common
event parameter types, the toolbox will automatically perform a
conversion from the HIToolbox type to an AXValue, so for position and
size, you can just put an HIPoint using typeHIPoint, or an HISize
using typeHISize, into the attribute value event parameter, and the
toolbox will do the right thing with it.
-eric
_______________________________________________
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