Issue with Accessibility Visible Text Range

I am trying to draw NSPanels on texts of other apps using AXObserverAddNotification with the attribute of kAXValueChangedNotification on an AXTextArea

I need to detect if the text range on that text area is visible on the screen and I use kAXVisibleCharacterRangeAttribute to get the visible text range but it doesn't include the top bar of the app and gives a range that starts from an index that is not visible.

This makes the panels drawn on top of the app's top app bar when scrolled to bottom like this gif

How do I exclude the top app bar for visible text range?

Hello, thanks for taking the time to post about your issue. Please take a few minutes to file feedback for this API to be more precise in considering this specific use case, you can find the Feedback Assistant tool here https://developer.apple.com/bug-reporting/

This will help us get information to the team asap and we can start taking a look

Issue with Accessibility Visible Text Range
 
 
Q