Re: Undo with a field editor
Re: Undo with a field editor
- Subject: Re: Undo with a field editor
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 25 Mar 2004 14:31:10 -0500
on 2004-03-25 12:11 PM, Darrin Cardani at email@hidden wrote:
>
I have a custom subclass of NSTextView that I'm using as the field
>
editor for an NSTableView because I need some custom behavior. It
>
works pretty well for that. However, I'd like for the text view to
>
have its own undo manager, as the undo stack gets corrupt when the
>
user types something in a field then does some other undoable action.
>
>
So I've made my document the delegate of the field editor, I've set
>
the field editor to allow undo, and I've written an
>
-undoManagerForTextView: method that returns a different undo manager
>
for the field editor. However, my delegate's -undoManagerForTextView:
>
method never gets called. Why not?
>
>
Is there something else I need to do in this case?
Recipe 7 of my book "Cocoa Recipes for Mac OS X: The Vermont Recipes" is
devoted to making undo work in text fields. It includes code for a subclass
of NSTextField, called VRUndoableTextField, that works in part by using a
custom field editor. The code, when all is said and done, is quite short and
simple. You might be able to adapt the subclass to your situation.
Be forewarned that, although the code is short, the topic itself is quite
difficult. There are some constraints on the use of the subclass -- some of
which were discovered after the book went to press.
You can download the code at www.stepwise.com/Articles/VermontRecipes. It is
commented to some extent, so you might not need the book to understand how
it works. The techniques I used may shed some light on the issues you're
facing.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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.