• 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: Strange behaviour of text insertion in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange behaviour of text insertion in NSTextView


  • Subject: Re: Strange behaviour of text insertion in NSTextView
  • From: Jeremy Dronfield <email@hidden>
  • Date: Tue, 20 Apr 2004 19:20:31 +0100

Thanks Ali, that's great. As a stopgap, I'd just been sending a setDocumentEdited after replaceCharactersInRange, which dirties the doc, but doesn't help with undo. How on earth did I manage to overlook didChangeText? Glug.

Thanks again.

Regards,
Jeremy


On 20 Apr 2004, at 7:04 pm, Ali Ozer wrote:

If you want to work directly with the text storage, and you want to have your changes treated as user changes (that is, marked undoable, cause the document to appear dirty, etc), you need to go through the following NSTextView methods around the changes:

- (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;
- (void)didChangeText;

for instance:

if ([textView shouldChangeTextInRange:replaceRange replacementString:[temp string]]) {
[[textView textStorage] replaceCharactersInRange:replaceRange withAttributedString:temp];
[textView didChangeText];
}

Ali
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Strange behaviour of text insertion in NSTextView (From: Jeremy Dronfield <email@hidden>)
 >Re: Strange behaviour of text insertion in NSTextView (From: Douglas Davidson <email@hidden>)
 >Re: Strange behaviour of text insertion in NSTextView (From: Jeremy Dronfield <email@hidden>)
 >Re: Strange behaviour of text insertion in NSTextView (From: Ali Ozer <email@hidden>)

  • Prev by Date: RE: [little OT] Licensing/Implementing in Cocoa/Obj-C
  • Next by Date: Re: [Q] Why unsolicited dealloc in NSKeyedUnarchiver?
  • Previous by thread: Re: Strange behaviour of text insertion in NSTextView
  • Next by thread: Re: Strange behaviour of text insertion in NSTextView
  • Index(es):
    • Date
    • Thread