• 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: Undo Manager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo Manager


  • Subject: Re: Undo Manager
  • From: James Housley <email@hidden>
  • Date: Tue, 24 Apr 2007 11:31:37 -0400

On Apr 23, 2007, at 4:49 PM, hac wrote:

Well, the undo manager only takes care of thigs the user changes, and
sometimes my application needs to edit the text view.

I'm trying to register an undo operation in a text view. At the
moment, my code for this is:

[[textArea undoManager] registerUndoWithTarget:textAre>a
selector:@selector(setString:)
object:[textArea string]];

Why? Make your model undoable, and your view and controller will take care of themselves.

Give your NSTextView an undo manager, and it will take care of itself.
_______________________________________________

I needed the exact same thing, so I just simulate the begin and end editing with the code below:


[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidBeginEditingNotification object:myTextView userInfo:nil];
[myTextView setString:oldString];
[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidEndEditingNotification object:myTextView userInfo:nil];


And it has worked without a problem for me.

Jim

--

/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
 X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden      http://www.FreeBSD.org     The Power to Serve
email@hidden  http://www.TheHousleys.net
---------------------------------------------------------------------
Fortune Not Found:
Abort, Retry, Ignore?



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Re: Undo Manager (From: hac <email@hidden>)

  • Prev by Date: Re: NSTask prevents crashreporter from running when child process crashes?
  • Next by Date: Changing selection color in NSTextView
  • Previous by thread: Re: Undo Manager
  • Next by thread: Removing subview crashes host application
  • Index(es):
    • Date
    • Thread