From 15c608fb1202d93226a1cf95d96bf2d8008daf42 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 3 Aug 2015 17:35:03 +0200 Subject: [PATCH] Accessibility: OS X: static text should have value instead of title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VoiceOver adds ", text" when reading QLabel when the Title instead of the Value attribute is set. Change-Id: Ic8f94844e858e490ec7e52856dccd4c0a09df88b Reviewed-by: Boris DuĊĦek Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/cocoa/qcocoaaccessibility.mm | 4 ++++ src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 03f585d19d3..56042e72ea4 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -332,6 +332,7 @@ bool hasValueAttribute(QAccessibleInterface *interface) Q_ASSERT(interface); const QAccessible::Role qtrole = interface->role(); if (qtrole == QAccessible::EditableText + || qtrole == QAccessible::StaticText || interface->valueInterface() || interface->state().checkable) { return true; @@ -343,6 +344,9 @@ bool hasValueAttribute(QAccessibleInterface *interface) id getValueAttribute(QAccessibleInterface *interface) { const QAccessible::Role qtrole = interface->role(); + if (qtrole == QAccessible::StaticText) { + return QCFString::toNSString(interface->text(QAccessible::Name)); + } if (qtrole == QAccessible::EditableText) { if (QAccessibleTextInterface *textInterface = interface->textInterface()) { // VoiceOver will read out the entire text string at once when returning diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 84d60df3ef1..fd5962cc349 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -282,6 +282,8 @@ static void convertLineOffset(QAccessibleTextInterface *text, int &line, int &of QSize qtSize = iface->rect().size(); return [NSValue valueWithSize: NSMakeSize(qtSize.width(), qtSize.height())]; } else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) { + if (iface->role() == QAccessible::StaticText) + return nil; return QCFString::toNSString(iface->text(QAccessible::Name)); } else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) { return QCFString::toNSString(iface->text(QAccessible::Description));