Re: Undo in NSTextFields?
Re: Undo in NSTextFields?
- Subject: Re: Undo in NSTextFields?
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 04 Jul 2002 06:09:59 -0400
on 02-07-03 11:11 PM, Simon Fraser at email@hidden wrote:
>
Is there an easy way to get Undo/Redo support in an NSTextField?
>
The docs say that an NSTextView can support undo automatically,
>
but not NSTextField.
At the "easy" level, just turn on the field editor's allowsUndo flag using
setAllowsUndo: in NSTextView. But then test the result in action and see
whether you like it. What happens is that "Undo Typing" and "Redo Cut",
etc., undo actions remain on the undo and redo stacks forever. You can build
up a pretty long list of editing undos and redos. Then you have to work back
through them to get to the last undo or redo of some other user control. It
quickly becomes unwieldy.
I've written a solution that clears the undo and redo stacks of intermediate
editing actions when you commit the data in the text field by tabbing out of
it, pressing Enter, etc. It substitutes a single undo action for the final
commit. The technique works in text fields, form fields, and table view
cells, and it can probably be made to work in any other control that is
bases on NSTextFieldCell in one way or another.
It will be explained in Vermont Recipes when Peachpit Press publishes the
book in two or three months. It's much too complicated to explain here. A
lot of email messages were exchanged while I was trying to get it right. You
can find them in the archives, but they probably won't give you the whole
answer.
--
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
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
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.