iOS: Accessibility: Set the correct traits for EditableText

Since the correct accessibility traits for EditableText are not
available as a direct enum value, then we depend on the defaults for a
UITextField to give us this information.

Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Fixes: QTBUG-93494
Pick-to: 6.1 5.15 5.12
Change-Id: If428414aec5ce571f0f8c0ecccffdbaf1c908120
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Andy Shaw 2021-05-07 15:31:55 +02:00 committed by Tor Arne Vestbø
parent a8a6558a84
commit 08cd5580df

View File

@ -157,8 +157,16 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement);
if (state.searchEdit)
traits |= UIAccessibilityTraitSearchField;
if (iface->role() == QAccessible::Button)
const auto accessibleRole = iface->role();
if (accessibleRole == QAccessible::Button) {
traits |= UIAccessibilityTraitButton;
} else if (accessibleRole == QAccessible::EditableText) {
static auto defaultTextFieldTraits = []{
auto *textField = [[[UITextField alloc] initWithFrame:CGRectZero] autorelease];
return textField.accessibilityTraits;
}();
traits |= defaultTextFieldTraits;
}
if (iface->valueInterface())
traits |= UIAccessibilityTraitAdjustable;