• 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: understanding NSTextView undo?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: understanding NSTextView undo?


  • Subject: Re: understanding NSTextView undo?
  • From: Jim Correia <email@hidden>
  • Date: Sat, 28 Dec 2002 21:43:43 -0500

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>)

  • Prev by Date: Fwd: ANNOUNCE: GNUstep Renaissance is out!
  • Next by Date: Re: Getting Mouse Moved Events
  • Previous by thread: Re: understanding NSTextView undo?
  • Next by thread: Re: understanding NSTextView undo?
  • Index(es):
    • Date
    • Thread