NSTextView is blank but mouse over scrollbar makes the content visible

52 Views Asked by At

I have an NSTextView inside an NSClipView inside an NSScrollView. It looks like this:

Screenshot

I set the text of the NSTextView like so:

[tv setString:@"Hello World"];

The window that contains the NSTextView and its container views is then shown like this:

[[NSApplication sharedApplication] runModalForWindow: win];

However, the text only appears the first time the window is shown. When closing the window and opening it another time, the NSTextView is empty.

Interestingly, the text magically appears when moving the mouse over the scrollbar area of the NSScrollView! So when the NSTextView is empty and the mouse is moved over the scrollbar area, the text suddenly appears. It's very weird!

It seems to be an issue with the latest macOS. The same project works fine on macOS 10.15. Even the binaries compiled on 10.15 for Intel work fine through Rosetta on an M1 Mac running Ventura but when compiling the project using Xcode 14 for the M1 architecture, this strange problem suddenly appears.

How to fix this please?

0

There are 0 best solutions below