• 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
NSTextView undo doesn't work for attributes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView undo doesn't work for attributes?


  • Subject: NSTextView undo doesn't work for attributes?
  • From: Keith Blount <email@hidden>
  • Date: Fri, 1 Apr 2005 12:56:47 -0800 (PST)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

Hello,

I am trying to programmatically add some attributed to
a text view like this:

NSAttributedString *attrStr = [[NSAttributedString
alloc] initWithString:string attributes:attribs];
	[self shouldChangeTextInRange:selRange
replacementString:string];
	[[self textStorage] replaceCharactersInRange:selRange
withAttributedString:attrStr];
	[self didChangeText];
	[attrStr release];

attribs is a dictionary that contains indenting in the
NSParagraphStyle attribute. Everything is called here
to set up undo, and yet undo fails to undo the
attributes. So if I use the above code and then hit
undo, the text attributes aren't restored to their
original state - they stay as they were set by
attribs.

Why aren't attributes undone? How can I make it so
that they are?

I tried separating the code into two stages: first I
replaced the string, and then I applied the attributes
using textStorage's addAttributes:range: - this worked
the first time I called undo (attributes were reset),
but if I call redo and undo again, again the
attributes are not reset.

Am I missing something? Surely NSTextView's
shouldChangeTextInRange:replacementString: and
didChangeText: should handle the undo for the whole
attributed string, not just the string part?

Many thanks for any pointers on what I am missing,
Keith

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Working with icns files in Cocoa
      • From: Dave Carpeneto <email@hidden>
  • Prev by Date: This has to be easy...
  • Next by Date: A Question about Bezier Paths..
  • Previous by thread: Re: This has to be easy...
  • Next by thread: Working with icns files in Cocoa
  • Index(es):
    • Date
    • Thread