Last time, we clipped the focus item to the accessible parent so that we considered only the visible portion of the item. But we found that this failed to clip some items, such as items in File Explorer. What’s going on?
The reason is that the parent of the clipped item is a wrapper and not the Tiles view container. We really need to intersect the item with parent elements all the way up the tree to get it fully clipped.
bool SetCursorPosToLocation(IAccessible* acc, LONG childId)
{
RECT rcObject;
if (GetAccessibleBounds(acc, childId, &rcObject)) {
RECT rcParent;
if (childId != CHILDID_SELF) {
if (GetAccessibleBounds(acc, CHILDID_SELF, &rcParent)) {
IntersectRect(&rcObject, &rcObject, &rcParent);
}
} else {
wil::com_ptr_nothrow<IAccessible> accParent(acc);
wil::com_ptr_nothrow<IDispatch> dispParent;
while (accParent->get_accParent(dispParent.put()) == S_OK &&
dispParent) {
/* auto */ accParent = dispParent.try_query<IAccessible>();
if (accParent &&
GetAccessibleBounds(accParent.get(), CHILDID_SELF,
&rcParent)) {
IntersectRect(&rcObject, &rcObject, &rcParent);
}
}
}
SetCursorPos(rcObject.right - 1, rcObject.bottom - 1);
return true;
}
return false;
}
I’m going to stop here because this seems to work reasonably well, except of course for the programs I noted earlier that simply refuse to report the caret position at all. I’m not sure what to do about those guys.
0 comments
Be the first to start the discussion.