• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextView, partial views of NSTextStorage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView, partial views of NSTextStorage


  • Subject: Re: NSTextView, partial views of NSTextStorage
  • From: Jesse Grosjean <email@hidden>
  • Date: Sun, 16 Sep 2007 11:15:40 -0400

Have you thought about just creating a substring of the full text view and editing that? Syncing the two ranges by copying back and forth when either is edited should be less trouble than trying to share a text storage and keeping it restricted to a particular range.

That's pretty much what I'm doing now, and from the feedback that I'm hearing I think I'll stick with that. The problem with this approach is that it's hard to make the synching part work well with undo. Once you get the details right you'll still be stuck with the problem of undo's not being coalesced, so you'll get an undo on the stack for every character typed.


Though I think someone on this list once asked about sharing the same text storage between several NSTextViews and got it solved ...

Yes, that's pretty easy and well supported and documented in the cocoa text docs. Just add a new NSLayoutManger/textcontainer/textview to the text storage for each separate NSTextView that you want.


maybe you could let the user view, but not edit, the other ranges? You could for example apply a custom (temporary?) style attribute to the characters that tells you which view can edit a particular piece of text, and then use shouldChangeTextInRange: to enforce that. Would that perhaps work better?

Unfortunately I need to allow people to edit the subranges.

Anyway thanks for everyone's feedback. My current solution seems to be working, I was just hoping that there was some trick in NSLayoutManager that would make my code simpler.

Jesse
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >NSTextView, partial views of NSTextStorage (From: Jesse Grosjean <email@hidden>)
 >Re: NSTextView, partial views of NSTextStorage (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: How to avoid excessive hard coding when programatically inserting Core Data entity ?
  • Next by Date: Re: How to avoid excessive hard coding when programatically inserting Core Data entity ?
  • Previous by thread: Re: NSTextView, partial views of NSTextStorage
  • Next by thread: Core Data: Build a popup with different options on each line
  • Index(es):
    • Date
    • Thread