Skip to content

Commit

Permalink
Also sub-pixel differences from default activation point
Browse files Browse the repository at this point in the history
  • Loading branch information
NickEntin committed Jan 25, 2024
1 parent 0d90140 commit c199a41
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ public final class AccessibilityHierarchyParser {
userInputLabels: userInputLabels,
shape: accessibilityShape(for: element.object, in: root),
activationPoint: root.convert(activationPoint, from: nil),
usesDefaultActivationPoint: (activationPoint == defaultActivationPoint(for: element.object)),
usesDefaultActivationPoint: activationPoint.approximatelyEquals(
defaultActivationPoint(for: element.object),
tolerance: 1 / (root.window?.screen ?? UIScreen.main).scale
),
customActions: element.object.accessibilityCustomActions?.map { $0.name } ?? [],
accessibilityLanguage: element.object.accessibilityLanguage
)
Expand Down Expand Up @@ -702,3 +705,13 @@ extension UIView {
}

}

// MARK: -

private extension CGPoint {

func approximatelyEquals(_ other: CGPoint, tolerance: CGFloat) -> Bool {
return abs(self.x - other.x) < tolerance && abs(self.y - other.y) < tolerance
}

}

0 comments on commit c199a41

Please sign in to comment.