Undo in formatted text fields
Undo in formatted text fields
- Subject: Undo in formatted text fields
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 10 Aug 2001 17:05:45 -0400
I can turn on "Undo Typing"/"Redo Typing" in all of a window's text fields
and form cells at once using this statement in my window controller's
windowDidLoad method:
[(NSTextView *)[[self window] fieldEditor:YES forObject:nil]
setAllowsUndo:YES]
As near as I can tell from the sparse documentation, that's the right way to
do it. But I'm not entirely sure. Two questions:
1. Is there a cleaner way to access my window's field editor?
Using a cast seems awkward.
2. How do I make Cocoa's text view Undo/Redo routines honor a custom
on-the-fly formatter attached to one or more text fields?
My custom on-the-fly formatter is ignored when I choose Undo Typing or Redo
Typing in a field with the formatter attached. The formatter's
isPartialStringValid:... Method never gets invoked. This results in bizarre
character strings in the text field.
3. Is there a way to turn on text view Undo/Redo on a text field-by-text
field basis?
The controlTextDidBeginEditing: delegate method and equivalents don't work
for this purpose, because they only turn on Undo/Redo after the first
character was typed in a text field, so they undo incorrectly (failing to
change the first character).
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
The AppleScript Sourcebook - www.AppleScriptSourcebook.com
Vermont Recipes - www.stepwise.com/Articles/VermontRecipes