Re: Strange behaviour of text insertion in NSTextView
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.