Camino only - Bug 303628: prevent spaces in keyword fields. r=cl sr=pink

This commit is contained in:
stuart.morgan%alumni.case.edu 2006-11-06 15:52:21 +00:00
parent 9256dabe8c
commit d2a6c28970
4 changed files with 37 additions and 0 deletions

View File

@ -102,6 +102,8 @@ static BookmarkInfoController* gSharedBookmarkInfoController = nil;
{
[self setShouldCascadeWindows:NO];
[[self window] setFrameAutosaveName:@"BookmarkInfoWindow"];
[mBookmarkKeywordField setFormatter:[[[BookmarkKeywordFormatter alloc] init] autorelease]];
[mFolderKeywordField setFormatter:[[[BookmarkKeywordFormatter alloc] init] autorelease]];
}
- (void)windowDidLoad

View File

@ -69,6 +69,12 @@ enum
kBookmarkItemEverythingChangedMask = 0xFFFFFFFE
};
// A formatter for keyword entry fields that prevents whitespace in keywords, since
// keywords with whitespace don't work.
@interface BookmarkKeywordFormatter : NSFormatter
{
}
@end
@interface BookmarkItem : NSObject <NSCopying>
{

View File

@ -87,6 +87,31 @@ NSString* const CaminoBookmarkKey = @"bookmark";
NSString* const CaminoFolderKey = @"folder";
NSString* const CaminoTrueKey = @"true";
@implementation BookmarkKeywordFormatter
- (NSString *)stringForObjectValue:(id)anObject
{
return anObject;
}
- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error
{
*anObject = string;
return YES;
}
- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
{
if ([partialString rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]].location != NSNotFound) {
*newString = [partialString stringByRemovingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
return NO;
}
return YES;
}
@end
#pragma mark -
@implementation BookmarkItem

View File

@ -291,6 +291,10 @@ static const unsigned int TableViewSolidVerticalGridLineMask = 1;
[self ensureBookmarks];
// set a formatter on the keyword column
BookmarkKeywordFormatter* keywordFormatter = [[[BookmarkKeywordFormatter alloc] init] autorelease];
[[[mBookmarksOutlineView tableColumnWithIdentifier:@"keyword"] dataCell] setFormatter:keywordFormatter];
// these should be settable in the nib. however, whenever
// I try, they disappear as soon as I've saved. Very annoying.
[mContainersTableView setAutosaveName:@"BMContainerView"];