mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Camino only - Bug 303628: prevent spaces in keyword fields. r=cl sr=pink
This commit is contained in:
parent
9256dabe8c
commit
d2a6c28970
@ -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
|
||||
|
@ -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>
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"];
|
||||
|
Loading…
Reference in New Issue
Block a user