1

This is kind of a followup on my previous question.

I have an NSTextView, which updates normally (well, actually there are some bugs in which it will draw awfully slowly until you pass your mouse over it. wierd.) if you are in the app. but the problem here is that I use

    [myWindow setLevel:NSFloatingWindowLevel];

to set it on top of the rest of windows. It is a small utiltiy, which you can hide and show with a NSStatusItem.

Boom: Notification. The app gets a string, and then I use [myTextView setString:somestring]; to put it on the NSTextView.

If the window has focus it obviously works well. But if the user is currently on another app... Any ideas on how I could make it work if the focus is currently somewhere else? I also have some NSTextFields, and they update great regardless of focus, but the NSTextView will go blank until the user clicks on the window. Actually, the NSStatusItem shows the window with

    [lyricWindow makeKeyAndOrderFront:nil];

which doesent redraw the NSTextView either. If app is hidden, the user is in another app, the update occurs, and then the user focuses the app the NSTextView will indeed be blank until the window is clicked. Is there a way of making the window believe it was clicked and has focus? Is there a way to force update or to make the NSTextView not require it to draw?

Thank you!

Kevin

Community
  • 1
  • 1
Kevin Chavez
  • 949
  • 1
  • 11
  • 27

1 Answers1

1

I fixed the problem! It required quite a bit of work to find a solution, for there is apparently nothing relevant on google, but if you're having a similar problem, the way I fixed it was turning off the Rich Text capabilities of the NSTextView in Interface Builder.

Im guessing it has to do with performance issues or something about the way text is styled. It works great now!

Kevin Chavez
  • 949
  • 1
  • 11
  • 27
  • Thanks, Kevin9764. Your answer led to my discovering that for my app (which needs Rich Text), turning off "Non-Contiguous Layout" for the NSTextView in Interface Builder makes it redraw properly even when another app has focus. – user532477 Mar 27 '16 at 22:48
  • To fix a related issue with NSTextView not redrawing I had to enable "Non-Contiguous Layout" – cdignam Apr 24 '19 at 17:54