Re: NSFormatter bugs
Re: NSFormatter bugs
- Subject: Re: NSFormatter bugs
- From: Bill Cheeseman <email@hidden>
- Date: Sat, 02 Mar 2002 10:36:50 -0500
on 02-03-02 6:34 AM, Bill Cheeseman at email@hidden wrote:
>
There appear to be two bugs in NSFormatter's new (with X 10.0), longer form
>
of the isPartialStringValid:... command, used to implement on-the-fly
>
filtering and formatting in text fields.
Here's a first crack at the implementation part of a category to work around
the two bugs in NSFormatter. It adds two methods to NSFormatter, which you
have to call at the beginning and end, respectively, of your override of the
new isPartialStringValid:... Command. These fixes should continue to work
after (if) Apple fixes the bugs. (The AppKit must be imported for this to
work.)
@implementation NSFormatter (VRFormatterBugFixes)
- (NSRange)origSelRangeForDeleteBug {
return [[[NSApp keyWindow] fieldEditor:NO forObject:nil]
selectedRange];
}
- (void)resetSelectionForEmptySelectionBug:(NSString *)partialString {
if ([partialString length] == 0) {
[[[NSApp keyWindow] fieldEditor:NO forObject:nil]
setSelectedRange:NSMakeRange(0, 0)];
}
}
--
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.