Re: Adding to NSTextView's current undo group?
Re: Adding to NSTextView's current undo group?
- Subject: Re: Adding to NSTextView's current undo group?
- From: Jesse Grosjean <email@hidden>
- Date: Wed, 12 Sep 2007 22:16:38 -0400
Does anybody know if there is a way to add undo invocations to
NSTextView's undo stack without starting a new undo group?
Keith,
You made this post back on 2005, but it didn't get any responses. I
have the same questions. I want make changes to a textStorage in an
undo friendly way. Right now I'm using this pattern:
if ([textView shouldChangeTextInRange:range
replacementString:@"..."]) {
[textStorage replaceCharactersInRange:range withString:@"..."];
[textView didChangeText];
}
It works, but it breaks undo coalescing, and I really want the text
system to coalesce my changes when possible. I've found that I can
replace the above with:
[textView setSelectedRange:range]
[textView insertText:@"..."]
That seems to work, but the insertText: method says that it shouldn't
be used except by input systems. So my question is what's the best
way to programatically edit text, while getting edits coalesces. And
if the answer is insertText: is there anything special that I need to
do to make it work right all the time?
Thanks,
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