• 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 shared state magic?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView shared state magic?


  • Subject: Re: NSTextView shared state magic?
  • From: Douglas Davidson <email@hidden>
  • Date: Sun, 10 Feb 2008 20:37:28 -0800


On Feb 9, 2008, at 8:23 AM, Keith Blount wrote:

I'm in the process of putting together a "page layout" view for my app, much like the "Wrap to Page" mode in TextEdit. So far, so good. However, I have a heavily subclassed NSTextView which has certain extra features - coloured annotations, highlight colours and so forth. When a layout manager has several text containers each with an associated text view, there are certain attributes that are shared across all of those text views - whether they use the font panel, have spell-checking enabled and so forth. Is there any way to tell a text view that it should share other, custom, attributes, too? For instance, if someone creates an annotation in my text view, they can set its colour. In doing so, my text view receives a - setAnnotationColor: message so that when the user creates another annotation, it will assume the colour they last used. When I have multiple text views, however, only the current text view receives this message, so that if the user creates
an annotation on another "page", it uses the colour last used on that page rather than the colour last used in the document.



What's the best way of getting other text views that use the same layout manager to share custom attributes as set in the - firstTextView? (Or do I have to do it all manually?)

Internally NSTextView has a private shared-state object, and a bit of mechanism for making sure that it is properly maintained as text views come and go. We don't really expose that to clients and subclasses, so for your own custom state you would have to do something similar yourself. It shouldn't be too difficult. Depending on how you are using the text system, one option would be to actually maintain your custom shared state in the layout manager, using a custom NSLayoutManager subclass, and have all of the text view methods involved call down to the layout manager to set and get their shared state.


Douglas Davidson

_______________________________________________

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 shared state magic? (From: Keith Blount <email@hidden>)

  • Prev by Date: Cocoaheads Lake Forest (92630) meeting 2/13 7pm - Topic: Cocoa 101
  • Next by Date: Re: Xcode 3.0, is it missing the Close Project menu item? sorry group
  • Previous by thread: NSTextView shared state magic?
  • Next by thread: Re: NSTextView shared state magic?
  • Index(es):
    • Date
    • Thread