Customizing/fixing NSTextView/NSScrollView default alignment in RTL

Let's say I have a NSTextView embedded in a NSClipView and NSScrollView.

Let's say that the application using this NSTextView is run in a right-to-left (RTL) language.

Let's say that because the text visible in the text view will always be LTR, the text view alignment is forced to left instead of the default natural setting and that this text is big enough to require a vertical and horizontal scrollers.

What I'm experiencing so far is that AppKit will scroll the NSTextView to the top right corner. Which would make sense if the contents of the textview was RTL. But it is not.

I looked at the documentation, headers, tried playing with a subclass of NSScrollView and play with the tile method, with the userInterfaceLayoutDirection property of the scrollview. No success so far.

[Q] How do you tell NSScrollView or NSTextView that the default scroll position is the top left corner and not the top right corner in such a case?

Environment: macOS 10.14.6 ; AppKit ; Objective-C (if that matters)

  • I watched WWDC 2022-10107 session and, though this session is very interesting, it still does not explain why the scroll position is wrong with RTL.

Add a Comment