Skip to content

Commit 78c612c

Browse files
committed
fix NSAccessibility frame calculation for STTextView
The fix ensures that accessibilityFrame(for:) returns coordinates in screen space by properly converting the text segment frame through the view hierarchy to screen coordinates.
1 parent 5ac3da2 commit 78c612c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/STTextViewAppKit/STTextView+NSAccessibilityProtocol.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ extension STTextView {
8383
// NSAccessibilityNavigableStaticText
8484

8585
open override func accessibilityFrame(for range: NSRange) -> NSRect {
86-
guard let textRange = NSTextRange(range, in: textContentManager) else {
86+
guard let textRange = NSTextRange(range, in: textContentManager),
87+
let segmentFrame = textLayoutManager.textSegmentFrame(in: textRange, type: .standard)
88+
else {
8789
return .zero
8890
}
89-
return textLayoutManager.textSegmentFrame(in: textRange, type: .standard) ?? .zero
91+
return window?.convertToScreen(contentView.convert(segmentFrame, to: nil)) ?? .zero
9092
}
9193

9294
open override func accessibilityLine(for index: Int) -> Int {

0 commit comments

Comments
 (0)