Skip to content
Merged
2 changes: 2 additions & 0 deletions Example/AccessibilitySnapshot/SwiftUITextEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ struct SwiftUITextEntry: View {
VStack {
TextField("SwiftUI Text Field", text: .constant(""))
TextField("SwiftUI Text Field", text: .constant("Value in Text Field"))
SecureField("Password", text: .constant(""))
SecureField("Password", text: .constant("secret123"))
if #available(iOS 14.0, *) {
TextEditor(text: .constant(""))
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,17 @@
/* Description for the 'text entry' accessibility trait */
"trait.text_field.description" = "Textfeld.";

/* Description for the 'secure text field' accessibility trait */
"trait.secure_text_field.description" = "Sicheres Textfeld.";

/* Hint describing how to use elements with the 'text entry' accessibility trait */
"trait.text_field.hint" = "Zum Bearbeiten doppeltippen.";

/* Hint describing how to use elements with the 'text entry' accessibility trait when they are being edited */
"trait.text_field_is_editing.hint" = "Den Rotor fΓΌr den Zuriff auf β€žRechtschreibfehler verwenden";

/* Hint describing how to use elements with the 'text entry' and 'scrollable' accessibility traits */
"trait.scrollable_text_field.hint" = "Zum Bearbeiten doppeltippen., Den Rotor fΓΌr den Zuriff auf β€žRechtschreibfehler verwenden";
/* Hint describing how to use elements with the 'text entry' and 'text area' accessibility traits */
"trait.text_area.hint" = "Zum Bearbeiten doppeltippen., Den Rotor fΓΌr den Zuriff auf β€žRechtschreibfehler verwenden";

/* Description for the 'is editing' accessibility trait */
"trait.text_field_is_editing.description" = "Bearbeiten";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,17 @@
/* Description for the 'text entry' accessibility trait */
"trait.text_field.description" = "Text Field.";

/* Description for the 'secure text field' accessibility trait */
"trait.secure_text_field.description" = "Secure Text Field.";

/* Hint describing how to use elements with the 'text entry' accessibility trait */
"trait.text_field.hint" = "Double tap to edit.";

/* Hint describing how to use elements with the 'text entry' accessibility trait when they are being edited */
"trait.text_field_is_editing.hint" = "Use the rotor to access Misspelled Words";

/* Hint describing how to use elements with the 'text entry' and 'scrollable' accessibility traits */
"trait.scrollable_text_field.hint" = "Double tap to edit., Use the rotor to access Misspelled Words";
/* Hint describing how to use elements with the 'text entry' and 'text area' accessibility traits */
"trait.text_area.hint" = "Double tap to edit., Use the rotor to access Misspelled Words";

/* Description for the 'is editing' accessibility trait */
"trait.text_field_is_editing.description" = "Is editing.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,17 @@
/* Description for the 'text entry' accessibility trait */
"trait.text_field.description" = "тСкстовоС ΠΏΠΎΠ»Π΅.";

/* Description for the 'secure text field' accessibility trait */
"trait.secure_text_field.description" = "Π—Π°Ρ‰ΠΈΡ‰Ρ‘Π½Π½ΠΎΠ΅ тСкстовоС ΠΏΠΎΠ»Π΅.";

/* Hint describing how to use elements with the 'text entry' accessibility trait */
"trait.text_field.hint" = "ΠΊΠΎΡΠ½ΠΈΡ‚Π΅ΡΡŒ Π΄Π²Π°ΠΆΠ΄Ρ‹, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Ρ€Π΅Π΄Π°ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ";

/* Hint describing how to use elements with the 'text entry' accessibility trait when they are being edited */
"trait.text_field_is_editing.hint" = "Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ Ρ€ΠΎΡ‚ΠΎΡ€ для доступа ΠΊ oбъeΠΊΡ‚Ρƒ: CΠ»ΠΎΠ²Π° с ошибками";

/* Hint describing how to use elements with the 'text entry' and 'scrollable' accessibility traits */
"trait.scrollable_text_field.hint" = "ΠΊΠΎΡΠ½ΠΈΡ‚Π΅ΡΡŒ Π΄Π²Π°ΠΆΠ΄Ρ‹, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Ρ€Π΅Π΄Π°ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ., Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ Ρ€ΠΎΡ‚ΠΎΡ€ для доступа ΠΊ oбъeΠΊΡ‚Ρƒ: CΠ»ΠΎΠ²Π° с ошибками";
/* Hint describing how to use elements with the 'text entry' and 'text area' accessibility traits */
"trait.text_area.hint" = "ΠΊΠΎΡΠ½ΠΈΡ‚Π΅ΡΡŒ Π΄Π²Π°ΠΆΠ΄Ρ‹, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Ρ€Π΅Π΄Π°ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ., Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ Ρ€ΠΎΡ‚ΠΎΡ€ для доступа ΠΊ oбъeΠΊΡ‚Ρƒ: CΠ»ΠΎΠ²Π° с ошибками";

/* Description for the 'is editing' accessibility trait */
"trait.text_field_is_editing.description" = "Π˜Π΄Π΅Ρ‚ ΠΏΡ€Π°Π²ΠΊΠ°";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ public extension UIAccessibilityTraits {
// Private traits (defined in UIAccessibility+SnapshotAdditions.swift)
(.textEntry, "textEntry"),
(.isEditing, "isEditing"),
(.secureTextField, "secureTextField"),
(.backButton, "backButton"),
(.tabBarItem, "tabBarItem"),
(.scrollable, "scrollable"),
(.textArea, "textArea"),
(.switchButton, "switchButton"),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,12 @@ extension NSObject {
}

if accessibilityTraits.contains(.textEntry) {
if accessibilityTraits.contains(.scrollable) {
// This is a UITextView/TextEditor
if accessibilityTraits.contains(.secureTextField) {
traitSpecifiers.append(strings.secureTextFieldTraitName)
} else {
// This is a UITextField/TextField
traitSpecifiers.append(strings.textEntryTraitName)
}

traitSpecifiers.append(strings.textEntryTraitName)

if accessibilityTraits.contains(.isEditing) {
traitSpecifiers.append(strings.isEditingTraitName)
}
Expand Down Expand Up @@ -235,9 +233,9 @@ extension NSObject {
if accessibilityTraits.contains(.isEditing) {
hintDescription = strings.textEntryIsEditingTraitHint
} else {
if accessibilityTraits.contains(.scrollable) {
if accessibilityTraits.contains(.textArea) {
// This is a UITextView/TextEditor
hintDescription = strings.scrollableTextEntryTraitHint
hintDescription = strings.textAreaTraitHint
} else {
// This is a UITextField/TextField
hintDescription = strings.textEntryTraitHint
Expand Down Expand Up @@ -366,11 +364,13 @@ extension NSObject {

let textEntryTraitName: String

let secureTextFieldTraitName: String

let textEntryTraitHint: String

let textEntryIsEditingTraitHint: String

let scrollableTextEntryTraitHint: String
let textAreaTraitHint: String

let isEditingTraitName: String

Expand Down Expand Up @@ -530,6 +530,11 @@ extension NSObject {
comment: "Description for the 'text entry' accessibility trait",
locale: locale
)
secureTextFieldTraitName = "Secure Text Field.".localized(
key: "trait.secure_text_field.description",
comment: "Description for the 'secure text field' accessibility trait",
locale: locale
)
textEntryTraitHint = "Double tap to edit.".localized(
key: "trait.text_field.hint",
comment: "Hint describing how to use elements with the 'text entry' accessibility trait",
Expand All @@ -540,9 +545,9 @@ extension NSObject {
comment: "Hint describing how to use elements with the 'text entry' accessibility trait when they are being edited",
locale: locale
)
scrollableTextEntryTraitHint = "Double tap to edit., Use the rotor to access Misspelled Words".localized(
key: "trait.scrollable_text_field.hint",
comment: "Hint describing how to use elements with the 'text entry' and 'scrollable' accessibility traits",
textAreaTraitHint = "Double tap to edit., Use the rotor to access Misspelled Words".localized(
key: "trait.text_area.hint",
comment: "Hint describing how to use elements with the 'text entry' and 'text area' accessibility traits",
locale: locale
)
isEditingTraitName = "Is editing.".localized(
Expand Down Expand Up @@ -573,18 +578,34 @@ extension String {

// MARK: -

// Private UIAccessibilityTraits constants. Bit positions sourced from AXRuntime.framework
// statics (_kAX*Trait symbols), as extracted in facebook/idb PrivateHeaders/AXRuntime/AXTraits.h.
//
// β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
// β”‚ Bit β”‚ Hex β”‚ Name β”‚ UIKit Source β”‚
// β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
// β”‚ 18 β”‚ 0x0000000000040000 β”‚ textEntry β”‚ UITextField, UITextView β”‚
// β”‚ 21 β”‚ 0x0000000000200000 β”‚ isEditing β”‚ First-responder text fields β”‚
// β”‚ 24 β”‚ 0x0000000001000000 β”‚ secureTextField β”‚ UITextField.isSecureTextEntry β”‚
// β”‚ 27 β”‚ 0x0000000008000000 β”‚ backButton β”‚ UINavigationBar back item β”‚
Comment thread
RoyalPineapple marked this conversation as resolved.
// β”‚ 28 β”‚ 0x0000000010000000 β”‚ tabBarItem β”‚ UITabBarButton β”‚
// β”‚ 47 β”‚ 0x0000800000000000 β”‚ textArea β”‚ UITextView, SwiftUI TextEditor β”‚
// β”‚ 53 β”‚ 0x0020000000000000 β”‚ switchButton β”‚ UISwitch β”‚
// β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
extension UIAccessibilityTraits {
static let textEntry = UIAccessibilityTraits(rawValue: 1 << 18) // 0x0000000000040000
static let textEntry = UIAccessibilityTraits(rawValue: 1 << 18)

static let isEditing = UIAccessibilityTraits(rawValue: 1 << 21)

static let isEditing = UIAccessibilityTraits(rawValue: 1 << 21) // 0x0000000000200000
static let secureTextField = UIAccessibilityTraits(rawValue: 1 << 24)

static let backButton = UIAccessibilityTraits(rawValue: 1 << 27) // 0x0000000008000000
static let backButton = UIAccessibilityTraits(rawValue: 1 << 27)

static let tabBarItem = UIAccessibilityTraits(rawValue: 1 << 28) // 0x0000000010000000
static let tabBarItem = UIAccessibilityTraits(rawValue: 1 << 28)

static let scrollable = UIAccessibilityTraits(rawValue: 1 << 47) // 0x0000800000000000
static let textArea = UIAccessibilityTraits(rawValue: 1 << 47)

static let switchButton = UIAccessibilityTraits(rawValue: 1 << 53) // 0x0020000000000000
static let switchButton = UIAccessibilityTraits(rawValue: 1 << 53)
}

// MARK: -
Expand Down
Loading