Accessibility: OS X: static text should have value instead of title

VoiceOver adds ", text" when reading QLabel when the Title instead of the
Value attribute is set.

Change-Id: Ic8f94844e858e490ec7e52856dccd4c0a09df88b
Reviewed-by: Boris Dušek <me@dusek.me>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
Frederik Gladhorn 2015-08-03 17:35:03 +02:00
parent 574c2e7fee
commit 15c608fb12
2 changed files with 6 additions and 0 deletions

View File

@ -332,6 +332,7 @@ bool hasValueAttribute(QAccessibleInterface *interface)
Q_ASSERT(interface); Q_ASSERT(interface);
const QAccessible::Role qtrole = interface->role(); const QAccessible::Role qtrole = interface->role();
if (qtrole == QAccessible::EditableText if (qtrole == QAccessible::EditableText
|| qtrole == QAccessible::StaticText
|| interface->valueInterface() || interface->valueInterface()
|| interface->state().checkable) { || interface->state().checkable) {
return true; return true;
@ -343,6 +344,9 @@ bool hasValueAttribute(QAccessibleInterface *interface)
id getValueAttribute(QAccessibleInterface *interface) id getValueAttribute(QAccessibleInterface *interface)
{ {
const QAccessible::Role qtrole = interface->role(); const QAccessible::Role qtrole = interface->role();
if (qtrole == QAccessible::StaticText) {
return QCFString::toNSString(interface->text(QAccessible::Name));
}
if (qtrole == QAccessible::EditableText) { if (qtrole == QAccessible::EditableText) {
if (QAccessibleTextInterface *textInterface = interface->textInterface()) { if (QAccessibleTextInterface *textInterface = interface->textInterface()) {
// VoiceOver will read out the entire text string at once when returning // VoiceOver will read out the entire text string at once when returning

View File

@ -282,6 +282,8 @@ static void convertLineOffset(QAccessibleTextInterface *text, int &line, int &of
QSize qtSize = iface->rect().size(); QSize qtSize = iface->rect().size();
return [NSValue valueWithSize: NSMakeSize(qtSize.width(), qtSize.height())]; return [NSValue valueWithSize: NSMakeSize(qtSize.width(), qtSize.height())];
} else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) { } else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) {
if (iface->role() == QAccessible::StaticText)
return nil;
return QCFString::toNSString(iface->text(QAccessible::Name)); return QCFString::toNSString(iface->text(QAccessible::Name));
} else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) { } else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) {
return QCFString::toNSString(iface->text(QAccessible::Description)); return QCFString::toNSString(iface->text(QAccessible::Description));