OS X accessibility: implement AXRangeForPosition

This enables users with "Speak text under mouse after delay" set in
VoiceOver Utility > Verbosity > Announcements to hover mouse over text
in QTextEdit and have it spoken by VoiceOver. It also allows users with
Trackpad Commander on to interact with the text area (VO-Shift-arrow
down) and "touch-explore" the text while holding their finger on the
trackpad and moving it around.

[ChangeLog][QtWidgets][Accessibility][OS X] VoiceOver users of QTextEdit
can now use mouse and touch exploration on trackpad to point at text to
have spoken to them.

Change-Id: I6cfaa8b1ff2179cce027b22539ba9ee4f3ee7f3f
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
bb10
Boris Dušek 2015-01-05 23:06:50 +01:00
parent c34efaf8ff
commit 250e80ceb9
1 changed files with 5 additions and 0 deletions

View File

@ -419,6 +419,11 @@ static void convertLineOffset(QAccessibleTextInterface *text, int &line, int &of
NSRange range = [parameter rangeValue];
QString text = iface->textInterface()->text(range.location, range.location + range.length);
return [[NSAttributedString alloc] initWithString: text.toNSString()];
} else if ([attribute isEqualToString: NSAccessibilityRangeForPositionParameterizedAttribute]) {
NSPoint nsPoint = [parameter pointValue];
QPoint point(static_cast<int>(nsPoint.x), static_cast<int>(qt_mac_flipYCoordinate(nsPoint.y)));
int offset = iface->textInterface()->offsetAtPoint(point);
return [NSValue valueWithRange:NSMakeRange(static_cast<NSUInteger>(offset), 1)];
}
return nil;
}