Hi,
Please ignore the first email sent by me. I sent it out by mistake.a
I write a custom class which has two
NSPopupButtonCells.
The interface looks like this:
@interface CustomCellArray:NSCell
{
NSMutableArray *
cells;
}
@end
in this array cells, it contains two NSPopupButtonCells. I
embed this custom cell CustomCellArray in the column B of a
NSTableView.
It works well to show the two NSPopupButtonCells, and
respond to the mouse events.
But I have problems when add accessibility support for
this kind of custom cell.
I override the NSTalbeView's -
(id)accessibilityHitTest:(NSPoint)point like this. the uiElements is an array
hosted in the NSTableView. the FauxUIElement has adopted the NSAccessibility
protocol.
-
(id)accessibilityHitTest:(NSPoint)point
{
id result = [super
accessibilityHitTest:point];
NSPoint windowPoint = [[self window]
convertScreenToBase:point];
NSPoint localPoint = [self
convertPoint:windowPoint fromView:nil];
NSInteger row = [self
rowAtPoint:localPoint];
NSInteger col = [self
columnAtPoint:localPoint];
if(col == 1 &&row
>= 0) //hit the valid row and the customized
column
{
if(uiElements ==
nil)
{
FauxUIElement
* ele1 = [FauxUIElement elementWithRole:NSAccessibilityPopUpButtonRole parent:
self];
FauxUIElement
* ele2 = [FauxUIElement elementWithRole:NSAccessibilityPopUpButtonRole parent:
self];
uiElements
= [[NSArray alloc] initWithObjects:ele1, ele2,
nil];
}
NSRect cellFrame = [self
frameOfCellAtColumn:col row: row];
NSRect
cell1 = cellFrame;
cell1.size.width =
cellFrame.size.width * 0.6;
NSRect cell2
= cellFrame;
cell2.origin.x =
cell1.origin.x +
cell1.size.width;
cell2.size.width =
cellFrame.size.width * 0.4;
if(NSPointInRect(localPoint, cell1))
//check whether it hits the first popupcell or the second
one.
return
[uiElements objectAtIndex:0];
else
if(NSPointInRect(localPoint,
cell2))
return
[uiElements objectAtIndex:1];
}
return result;
}
But when I use the
accessibility inspector to check it. the two cells are marked as
AXUnknown.
I also wonder is it a right place
to override the accessiblityHitTest in NSTableView to achieve
this?
Any
suggestions?
Thanks.