NSFormatter bug (workaround)
NSFormatter bug (workaround)
- Subject: NSFormatter bug (workaround)
- From: Bill Cheeseman <email@hidden>
- Date: Tue, 07 Aug 2001 08:59:09 -0400
Sorry to keep harping on this, but I found a workaround for the insertion
point bug when overriding the new, long form of isPartialStringValid:... in
NSFormatter.
At the end of my override of that method, before returning YES or NO, I
insert this:
if ([*partialStringPtr length] == 0) {
[[[NSApp keyWindow] fieldEditor:NO forObject:nil]
setSelectedRange:*proposedSelRangePtr];
}
The fact that this completely solves the disappearing insertion point
problem pretty much proves that there is a bug somewhere in Cocoa in
connection with the isPartialStringValid:... method in the case when the
*partialStringPtr parameter holds a zero-length string, doesn't it?
I believe it is safe to access the current field editor in this way from a
formatter, since the fact that a formatter is running guarantees that my
text field's window is the key window and that the key window's field editor
is currently in use by my text field. Or am I overlooking something?
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
The AppleScript Sourcebook - www.AppleScriptSourcebook.com
Vermont Recipes - www.stepwise.com/Articles/VermontRecipes