• 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:22:53 -0500

On Saturday, December 28, 2002, at 05:17 PM, Greg Titus wrote:

So a couple possible ways to keep the text system from doing this is to:
1) Add your own undo invocation to the stack when you save (which doesn't need to do anything).

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

Then when you next make a typing change, the text system looks at the top of the stack, sees it isn't a typing change, and makes a new undo group. You could also use this "on save" undo invocation call something that brings up a "you are about to go back before this file was saved" warning dialog.

I assume project builder is doing something like this.

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.

Yes, that would be nice.

I guess I would approach this by using your own controller object with -insertMacro: and -deleteMacro: methods, and have them register each other to undo each other's actions. You can set the selection range appropriately in each instead of depending upon NSTextView's undo management.

I could go down this road. The only down side is that I'd have to do all that shouldChangeTextInRange: replacementString: does except for creating the undo object (so if the delegate wanted to reject the change, it could, etc.)

Hope this helps

It helps a lot. 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.

  • Follow-Ups:
    • Re: understanding NSTextView undo?
      • From: Jim Correia <email@hidden>
    • Re: understanding NSTextView undo?
      • From: Jim Correia <email@hidden>
References: 
 >Re: understanding NSTextView undo? (From: Greg Titus <email@hidden>)

  • Prev by Date: Re: Just a single didBecomeMain/didResignMain event being fired
  • Next by Date: Fwd: ANNOUNCE: GNUstep Renaissance is out!
  • Previous by thread: Re: understanding NSTextView undo?
  • Next by thread: Re: understanding NSTextView undo?
  • Index(es):
    • Date
    • Thread