From 250e80ceb98e96514c886a8fb0d507fced1fc982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Du=C5=A1ek?= Date: Mon, 5 Jan 2015 23:06:50 +0100 Subject: [PATCH] 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 --- src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 1cb51a37bc..47ba50a443 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -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(nsPoint.x), static_cast(qt_mac_flipYCoordinate(nsPoint.y))); + int offset = iface->textInterface()->offsetAtPoint(point); + return [NSValue valueWithRange:NSMakeRange(static_cast(offset), 1)]; } return nil; }