Update unfocused NSTextView
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 t开发者_开发技巧hey 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
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!
精彩评论