Re: Undo Manager
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