Re: What is the preferred way to set NSTextView content from NSAttributedString?

2020-02-03 Thread Martin Wierschin via Cocoa-dev
Yes, working through the NSTextStorage is the way to go. To replace its entire contents you can use -replaceCharactersInRange:withAttributedString: with a range that encompasses all

Re: What is the preferred way to set NSTextView content from NSAttributedString?

2020-02-02 Thread Jonathan Prescott via Cocoa-dev
Looking at the documentation for NSTextView, it is highly recommended that you manipulate the NSTextStorage associated with the view. NSTextStorage is a sub-class of NSMutableAttributedtString, so you have all of those capabilities as well. I’m just getting into this as well for my console

Re: What is the preferred way to set NSTextView content from NSAttributedString?

2020-02-02 Thread Greg Weston via Cocoa-dev
> - I want to set the displayed contents of V to T2. > > What is/are the recommended way/s to do this? > > *I would hope that I could assign V.attributedString = T2, but alas the > world does not seem to be this simple.* The documentation suggests you should be working with the view’s

RE: What is the preferred way to set NSTextView content from NSAttributedString?

2020-02-02 Thread Jonathan Prescott via Cocoa-dev
Did you tell V that it needs to re-load it’s display? There is a method on NSView (from which NSTextView is derived) called “needsDisplay(sic)” which sets a flag on the view so that the view will re-draw its content the next display cycle. So, after you set the content to T2, you need to call