Ignore:
Timestamp:
01/02/03 05:30:03 (21 years ago)
Author:
Nicholas Riley
Message:

Updated for Pester 1.1a5 (very limited release).

Pester 1.1a4 was never released.

Location:
trunk/Cocoa/Pester/Source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source

    • Property svn:ignore
      •  

        old new  
        11build
         2.gdb_history
  • trunk/Cocoa/Pester/Source/NJRIntegerFilter.m

    r21 r53  
    77//
    88
    9 // based on MyIntegerFilter
    10 // Copyright © 2001 Bill Cheeseman. All rights reserved.
     9// based on MyIntegerFilter, later VRIntegerNumberFilter
     10// Copyright © 2001-2002 Bill Cheeseman. All rights reserved.
    1111
    1212#import "NJRIntegerFilter.h"
     
    1414@implementation NJRIntegerFilter
    1515
    16 // Input filter
     16// Input validation
    1717
    18 - (BOOL)isPartialStringValid:(NSString **)partialStringPtr proposedSelectedRange:(NSRangePointer)proposedSelRangePtr originalString:(NSString *)origString originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString **)error {
    19 
    20     // Override method to enable NSControl delegate method control:didFailToValidatePartialString:errorDescription: to
    21     // reject invalid keypresses. Filters out keyboard input characters other than "1" .. "9".
     18- (BOOL)isPartialStringValid:(NSString **)partialStringPtr proposedSelectedRange:(NSRangePointer)proposedSelRangePtr originalString:(NSString *)origString originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString **)error;
     19{
     20    // Override method to enable NSControl delegate method control:didFailToValidatePartialString:errorDescription: to reject invalid keypresses. Filters out keyboard input characters other than 0..9.
    2221    if ([[*partialStringPtr substringWithRange:NSMakeRange(origSelRange.location, (*proposedSelRangePtr).location - origSelRange.location)] rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet] options:NSLiteralSearch].location != NSNotFound) {
    23         *error = NSLocalizedString(@"Input is not an integer", @"Presented when user value not a numeric digit");
    24         return NO; // Reject *partialStringPtr as typed, invoke delegate method
     22        *error = NSLocalizedString(@"Input is not an integer.", @"Presented when user value not a numeric digit");
     23        return NO; // Reject *partialStringPtr as typed, invoke delegate method for error handling
    2524    }
    26 
    27     if ([*partialStringPtr length] == 0) {
    28         // Work around NSFormatter issue in Mac OS X 10.0.
    29         [[[NSApp keyWindow] fieldEditor:NO forObject:nil] setSelectedRange:*proposedSelRangePtr];
    30     }
    31 
     25    *error = nil;
    3226    return YES; // Accept *partialStringPtr as typed
    3327}
Note: See TracChangeset for help on using the changeset viewer.