diff options
author | avenjamin <avenjamin@gmail.com> | 2009-02-28 05:02:27 +0000 |
---|---|---|
committer | avenjamin <avenjamin@gmail.com> | 2009-02-28 05:02:27 +0000 |
commit | ce5a6e4f3d90dcc775f4d81f19e20c412eb5af23 (patch) | |
tree | 977f502a938af428f9433e9850819d3887ddda0d /Source/SPDataCellFormatter.m | |
parent | b8c9157be916c058f867e24e1d087271de022047 (diff) | |
download | sequelpro-ce5a6e4f3d90dcc775f4d81f19e20c412eb5af23.tar.gz sequelpro-ce5a6e4f3d90dcc775f4d81f19e20c412eb5af23.tar.bz2 sequelpro-ce5a6e4f3d90dcc775f4d81f19e20c412eb5af23.zip |
Cleaned up warnings when building against 10.5 SDK
Diffstat (limited to 'Source/SPDataCellFormatter.m')
-rw-r--r-- | Source/SPDataCellFormatter.m | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/SPDataCellFormatter.m b/Source/SPDataCellFormatter.m index 4f005c23..ae03a441 100644 --- a/Source/SPDataCellFormatter.m +++ b/Source/SPDataCellFormatter.m @@ -40,6 +40,8 @@ } #endif + + - (NSString *)stringForObjectValue:(id)anObject { @@ -72,16 +74,25 @@ - (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error { - // No limit set + // No limit set if (textLimit == 0) return YES; + // A single character over the length of the string - likely typed. Prevent the change. + if ([partialString length] == textLimit + 1) { + NSBeep(); + return NO; + } + + // If the string is considerably longer than the limit, likely pasted. Accept but truncate. if ([partialString length] > textLimit) { NSBeep(); - newString = [NSString stringWithCharacters:partialString length:textLimit]; + *newString = [NSString stringWithString:[partialString substringToIndex:textLimit]]; + return NO; } - return ([partialString length] <= textLimit); + // Length inside limit. + return YES; } @end |