Re: Adding actions to undo manager
Re: Adding actions to undo manager
- Subject: Re: Adding actions to undo manager
- From: Ryan Joseph <email@hidden>
- Date: Tue, 16 Jun 2009 08:39:55 +0700
On Jun 16, 2009, at 8:34 AM, Kyle Sluder wrote:
On Mon, Jun 15, 2009 at 6:18 PM, Ryan Joseph<email@hidden
> wrote:
I'm not sure I follow you. How do I know the user wants to undo and
that it
was in response to my change of the NSTextStorage? It seems like
one way or
another I need to keep a stack of changes with information on what
operation
they performed to the NSTextStorage. Thanks.
You already can.
Undo and Redo are typically view-centered operations. That is, they
perform actions in response to things the user does with your views.
If they type into an NSTextView, the NSTextView ensures that, in
response to their typing, the undo stack is updated.
You're essentially assuming the role of NSTextView here. Instead of
providing methods like -cut:, you're providing some method
-doCustomThing:. -doCustomThing:, like -cut:, operates on the
NSTextStorage instance. And just like Apple had to when they wrote
-cut:, you need to provide undo/redo support in your implementation of
-doCustomThing:.
So I define my new "action" and within that method I need to call
registerUndoWithTarget:selector:object: to record the action with
NSUndoManager? I assume then when the user undos is clear the text and
when redo it will call that method which is my "action". Does that
sound correct? Thanks for helping.
--Kyle Sluder
Regards,
Josef
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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