diff options
author | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2018-11-21 10:53:26 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2019-05-16 13:37:24 +0200 |
commit | 2bf7b15446198e354b238d4ec455ae9214965702 (patch) | |
tree | a581e8915a47e8ed293aecc8f7fd3768bb227c5d /src/plugins/platforms | |
parent | cfdbfcebbda5f26b89c70df6b191b17ef242e9d7 (diff) |
macOS accessibility: implement accessibilityLabel
We had an implementation of this based on the old attribute
based API, which also works. This cleans it up and adds
the setter.
Change-Id: I886fc9c89ee08b9f4f9aabec00ac1a5b9a800c6f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 4c72cbd501..675736ca5d 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -282,6 +282,22 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of return QCocoaScreen::mapToNative(iface->rect()); } +- (NSString*)accessibilityLabel { + QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); + if (!iface || !iface->isValid()) { + qWarning() << "Called accessibilityLabel on invalid object: " << axid; + return nil; + } + return iface->text(QAccessible::Description).toNSString(); +} + +- (void)setAccessibilityLabel:(NSString*)label{ + QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); + if (!iface || !iface->isValid()) + return; + iface->setText(QAccessible::Description, QString::fromNSString(label)); +} + - (id) minValueAttribute:(QAccessibleInterface*)iface { if (QAccessibleValueInterface *val = iface->valueInterface()) return @(val->minimumValue().toDouble()); @@ -332,7 +348,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of return nil; return iface->text(QAccessible::Name).toNSString(); } else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) { - return iface->text(QAccessible::Description).toNSString(); + return [self accessibilityLabel]; } else if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) { return @(!iface->state().disabled); } else if ([attribute isEqualToString:NSAccessibilityValueAttribute]) { |