Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: understanding NSTextView undo?



On Saturday, December 28, 2002, at 09:22 PM, Jim Correia wrote:

But won't that add an undo state such that when the user choses undo nothing happens? (Or will it be grouped with another state by the undo manager, so the user won't notice?)

I tried this. I added

[[[self undoManager] prepareWithInvocationTarget: textView] setSelectedRange: selectedRange];

and it indeed introduces a dummy state that the user sees. If I did the undo past save alert that would solve the problem. Ultimately I think I'll file a bug requesting that there be a message you can send to NSTextView to tell it to stop coalescing typing.

2) You could also do something when you save to simply convince the text view that it should make a new typing "group". Probably the easiest way is to simply change the selection (to anything different), then change it back. NSTextView starts a new typing group if you change the selection between typing characters.

Even if I put the selected range right where it was? I'll have to give that a try. Thanks.

Unfortunately this didn't seem to work (if I want to preserve the range by putting it back). I modifying the save code for TextEdit like this.

NSTextView *textView = [self firstTextView];
NSRange selectedRange = [textView selectedRange];
NSRange dummyRange = selectedRange;

dummyRange.location = dummyRange.length = 0;
[[self firstTextView] setSelectedRange: dummyRange];
[[self firstTextView] setSelectedRange: selectedRange];

Thanks,
Jim
_______________________________________________
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: 
 >Re: understanding NSTextView undo? (From: Jim Correia <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.