From a7647939f1c9dca4410be6866ed8c51912cb5173 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 15 Nov 2012 17:01:15 +0100 Subject: [PATCH] Accessibility Mac: Return textArea as role for multi line text. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I88eb4746463b7372c2dfe089ba74ea4cb0098396 Reviewed-by: Morten Johan Sørvig Reviewed-by: Jan Arve Sæther --- src/plugins/platforms/cocoa/qcocoaaccessibility.h | 2 +- src/plugins/platforms/cocoa/qcocoaaccessibility.mm | 7 +++++-- src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 2 +- src/plugins/platforms/cocoa/qnsviewaccessibility.mm | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.h b/src/plugins/platforms/cocoa/qcocoaaccessibility.h index e2a64331ac..6af13c8f92 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.h +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.h @@ -77,7 +77,7 @@ namespace QCocoaAccessible { demand. */ -NSString *macRole(QAccessible::Role); +NSString *macRole(QAccessibleInterface *interface); bool shouldBeIgnrored(QAccessibleInterface *interface); NSString *getTranslatedAction(const QString &qtAction); NSMutableArray *createTranslatedActionsList(const QStringList &qtActions); diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 66cb979031..9733d12d26 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -149,8 +149,9 @@ static void populateRoleMap() Returns a Mac accessibility role for the given interface, or NSAccessibilityUnknownRole if no role mapping is found. */ -NSString *macRole(QAccessible::Role qtRole) +NSString *macRole(QAccessibleInterface *interface) { + QAccessible::Role qtRole = interface->role(); QMacAccessibiltyRoleMap &roleMap = *qMacAccessibiltyRoleMap(); if (roleMap.isEmpty()) @@ -160,6 +161,8 @@ NSString *macRole(QAccessible::Role qtRole) if (roleMap.contains(qtRole)) { // MAC_ACCESSIBILTY_DEBUG() << "return" << roleMap[qtRole]; + if (roleMap[qtRole] == NSAccessibilityTextFieldRole && interface->state().multiLine) + return NSAccessibilityTextAreaRole; return roleMap[qtRole]; } @@ -190,7 +193,7 @@ bool shouldBeIgnrored(QAccessibleInterface *interface) role == QAccessible::ToolBar) // Access the tool buttons directly. return true; - NSString *mac_role = macRole(interface->role()); + NSString *mac_role = macRole(interface); if (mac_role == NSAccessibilityWindowRole || // We use the system-provided window elements. mac_role == NSAccessibilityGroupRole || mac_role == NSAccessibilityUnknownRole) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index cc1d393029..04284af594 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -59,7 +59,7 @@ static QAccessibleInterface *acast(void *ptr) self = [super init]; if (self) { accessibleInterface = anQAccessibleInterface; - role = QCocoaAccessible::macRole(acast(accessibleInterface)->role()); + role = QCocoaAccessible::macRole(acast(accessibleInterface)); parent = aParent; } diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index 4825178645..5c39402377 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -62,7 +62,7 @@ - (id)accessibilityAttributeValue:(NSString *)attribute { if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { if (m_accessibleRoot) - return QCocoaAccessible::macRole(m_accessibleRoot->role()); + return QCocoaAccessible::macRole(m_accessibleRoot); return NSAccessibilityUnknownRole; } else if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) { return NSAccessibilityRoleDescriptionForUIElement(self);