Last change
on this file was 53, checked in by Nicholas Riley, 22 years ago |
Updated for Pester 1.1a5 (very limited release).
Pester 1.1a4 was never released.
|
File size:
1.3 KB
|
Line | |
---|
1 | //
|
---|
2 | // NJRIntegerFilter.m
|
---|
3 | // HostLauncher
|
---|
4 | //
|
---|
5 | // Created by Nicholas Riley on Tue Dec 18 2001.
|
---|
6 | // Copyright (c) 2001 Nicholas Riley. All rights reserved.
|
---|
7 | //
|
---|
8 |
|
---|
9 | // based on MyIntegerFilter, later VRIntegerNumberFilter
|
---|
10 | // Copyright © 2001-2002 Bill Cheeseman. All rights reserved.
|
---|
11 |
|
---|
12 | #import "NJRIntegerFilter.h"
|
---|
13 |
|
---|
14 | @implementation NJRIntegerFilter
|
---|
15 |
|
---|
16 | // Input validation
|
---|
17 |
|
---|
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.
|
---|
21 | if ([[*partialStringPtr substringWithRange:NSMakeRange(origSelRange.location, (*proposedSelRangePtr).location - origSelRange.location)] rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet] options:NSLiteralSearch].location != NSNotFound) {
|
---|
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
|
---|
24 | }
|
---|
25 | *error = nil;
|
---|
26 | return YES; // Accept *partialStringPtr as typed
|
---|
27 | }
|
---|
28 |
|
---|
29 | @end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.