On Apr 25, 2013, at 5:27 PM, Jason Brennan wrote: > What I’m trying to do is have an NSTextView and add custom NSView subviews to > it, but have it so the text can layout around the subviews. > > Right now, I can easily add a subview to the textview but of course, that > goes into the textview and the text is ignorant of the subviews, so it just > runs over/under the subview. Not what I’d like, of course. > > So I’d like to be able to add my own views at least in “block” (like when an > HTML element is a block element, so it’s on its own line), and maybe “inline” > as well (that is, a subview in line with the text, just like how an HTML > element can be inline) although this is not absolutely required. > > I can’t quite figure out how to make this work. The only way I’ve seen that > things can be added to a textview are with Text Attachments, but those seem > relegated to only images/files, and only in an NSCell, which doesn’t contain > (to my knowledge) an arbitrary NSView. > > I feel like this should be possible though, where do I start?
What you want is possible, but likely difficult. First, you need to thoroughly understand the Cocoa text architecture and layout. From this alone, you would have known that subclassing NSTextView is likely the wrong approach. You will also need to see the WWDC 2010 talk on advanced text techniques. That will give you an idea about inline views. An all-Cocoa solution might not be the best choice, however, although it will probably be easier (though you won't think so as you trudge through it, take it from me ;-), though likely less performant. You may quickly get into having too many NSViews, which are heavy and slow. Anyway, you would likely start with an NSView subclass, using multiple NSTextViews when text is divided by a "block" view, and inline views for the inline part. You will also likely want to become familiar with NSTextBlock, which will make having text flow around an object much easier. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com