diff --git a/camino/CHAutoCompleteTextField.h b/camino/CHAutoCompleteTextField.h index 1a3dd60333af..847b86d16a71 100644 --- a/camino/CHAutoCompleteTextField.h +++ b/camino/CHAutoCompleteTextField.h @@ -85,6 +85,7 @@ - (void) onRowClicked:(NSNotification *)aNote; - (void) onBlur:(NSNotification *)aNote; - (void) onResize:(NSNotification *)aNote; +- (void) onUndoOrRedo:(NSNotification *)aNote; - (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation; - (id) fieldEditor; diff --git a/camino/CHAutoCompleteTextField.mm b/camino/CHAutoCompleteTextField.mm index 39c2cf61981c..9fd20c4a4c43 100644 --- a/camino/CHAutoCompleteTextField.mm +++ b/camino/CHAutoCompleteTextField.mm @@ -91,7 +91,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) mListener = (nsIAutoCompleteListener *)new AutoCompleteListener(self); NS_IF_ADDREF(mListener); - [self setDelegate: self]; + [self setFont:[NSFont controlContentFontOfSize:0]]; + [self setDelegate: self]; // XXX the owner of the textfield should set this [self setSession:@"history"]; @@ -151,6 +152,14 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResize:) name:NSWindowDidResizeNotification object:nil]; + // listen for Undo/Redo to make sure autocomplete doesn't get horked. + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidRedoChangeNotification + object:[[self fieldEditor] undoManager]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidUndoChangeNotification + object:[[self fieldEditor] undoManager]]; + // read the user default on if we should auto-complete the text field as the user // types or make them pick something from a list (a-la mozilla). mCompleteWhileTyping = [[NSUserDefaults standardUserDefaults] boolForKey:USER_DEFAULTS_AUTOCOMPLETE_WHILE_TYPING]; @@ -501,6 +510,11 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self resizePopup]; } +- (void) onUndoOrRedo:(NSNotification *)aNote +{ + [self clearResults]; +} + // NSTextField delegate ////////////////////////////////// - (void)controlTextDidChange:(NSNotification *)aNote { diff --git a/camino/src/browser/AutoCompleteTextField.h b/camino/src/browser/AutoCompleteTextField.h index 1a3dd60333af..847b86d16a71 100644 --- a/camino/src/browser/AutoCompleteTextField.h +++ b/camino/src/browser/AutoCompleteTextField.h @@ -85,6 +85,7 @@ - (void) onRowClicked:(NSNotification *)aNote; - (void) onBlur:(NSNotification *)aNote; - (void) onResize:(NSNotification *)aNote; +- (void) onUndoOrRedo:(NSNotification *)aNote; - (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation; - (id) fieldEditor; diff --git a/camino/src/browser/AutoCompleteTextField.mm b/camino/src/browser/AutoCompleteTextField.mm index 39c2cf61981c..9fd20c4a4c43 100644 --- a/camino/src/browser/AutoCompleteTextField.mm +++ b/camino/src/browser/AutoCompleteTextField.mm @@ -91,7 +91,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) mListener = (nsIAutoCompleteListener *)new AutoCompleteListener(self); NS_IF_ADDREF(mListener); - [self setDelegate: self]; + [self setFont:[NSFont controlContentFontOfSize:0]]; + [self setDelegate: self]; // XXX the owner of the textfield should set this [self setSession:@"history"]; @@ -151,6 +152,14 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResize:) name:NSWindowDidResizeNotification object:nil]; + // listen for Undo/Redo to make sure autocomplete doesn't get horked. + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidRedoChangeNotification + object:[[self fieldEditor] undoManager]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidUndoChangeNotification + object:[[self fieldEditor] undoManager]]; + // read the user default on if we should auto-complete the text field as the user // types or make them pick something from a list (a-la mozilla). mCompleteWhileTyping = [[NSUserDefaults standardUserDefaults] boolForKey:USER_DEFAULTS_AUTOCOMPLETE_WHILE_TYPING]; @@ -501,6 +510,11 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self resizePopup]; } +- (void) onUndoOrRedo:(NSNotification *)aNote +{ + [self clearResults]; +} + // NSTextField delegate ////////////////////////////////// - (void)controlTextDidChange:(NSNotification *)aNote { diff --git a/chimera/CHAutoCompleteTextField.h b/chimera/CHAutoCompleteTextField.h index 1a3dd60333af..847b86d16a71 100644 --- a/chimera/CHAutoCompleteTextField.h +++ b/chimera/CHAutoCompleteTextField.h @@ -85,6 +85,7 @@ - (void) onRowClicked:(NSNotification *)aNote; - (void) onBlur:(NSNotification *)aNote; - (void) onResize:(NSNotification *)aNote; +- (void) onUndoOrRedo:(NSNotification *)aNote; - (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation; - (id) fieldEditor; diff --git a/chimera/CHAutoCompleteTextField.mm b/chimera/CHAutoCompleteTextField.mm index 39c2cf61981c..9fd20c4a4c43 100644 --- a/chimera/CHAutoCompleteTextField.mm +++ b/chimera/CHAutoCompleteTextField.mm @@ -91,7 +91,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) mListener = (nsIAutoCompleteListener *)new AutoCompleteListener(self); NS_IF_ADDREF(mListener); - [self setDelegate: self]; + [self setFont:[NSFont controlContentFontOfSize:0]]; + [self setDelegate: self]; // XXX the owner of the textfield should set this [self setSession:@"history"]; @@ -151,6 +152,14 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResize:) name:NSWindowDidResizeNotification object:nil]; + // listen for Undo/Redo to make sure autocomplete doesn't get horked. + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidRedoChangeNotification + object:[[self fieldEditor] undoManager]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidUndoChangeNotification + object:[[self fieldEditor] undoManager]]; + // read the user default on if we should auto-complete the text field as the user // types or make them pick something from a list (a-la mozilla). mCompleteWhileTyping = [[NSUserDefaults standardUserDefaults] boolForKey:USER_DEFAULTS_AUTOCOMPLETE_WHILE_TYPING]; @@ -501,6 +510,11 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self resizePopup]; } +- (void) onUndoOrRedo:(NSNotification *)aNote +{ + [self clearResults]; +} + // NSTextField delegate ////////////////////////////////// - (void)controlTextDidChange:(NSNotification *)aNote { diff --git a/chimera/src/browser/AutoCompleteTextField.h b/chimera/src/browser/AutoCompleteTextField.h index 1a3dd60333af..847b86d16a71 100644 --- a/chimera/src/browser/AutoCompleteTextField.h +++ b/chimera/src/browser/AutoCompleteTextField.h @@ -85,6 +85,7 @@ - (void) onRowClicked:(NSNotification *)aNote; - (void) onBlur:(NSNotification *)aNote; - (void) onResize:(NSNotification *)aNote; +- (void) onUndoOrRedo:(NSNotification *)aNote; - (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation; - (id) fieldEditor; diff --git a/chimera/src/browser/AutoCompleteTextField.mm b/chimera/src/browser/AutoCompleteTextField.mm index 39c2cf61981c..9fd20c4a4c43 100644 --- a/chimera/src/browser/AutoCompleteTextField.mm +++ b/chimera/src/browser/AutoCompleteTextField.mm @@ -91,7 +91,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) mListener = (nsIAutoCompleteListener *)new AutoCompleteListener(self); NS_IF_ADDREF(mListener); - [self setDelegate: self]; + [self setFont:[NSFont controlContentFontOfSize:0]]; + [self setDelegate: self]; // XXX the owner of the textfield should set this [self setSession:@"history"]; @@ -151,6 +152,14 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResize:) name:NSWindowDidResizeNotification object:nil]; + // listen for Undo/Redo to make sure autocomplete doesn't get horked. + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidRedoChangeNotification + object:[[self fieldEditor] undoManager]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUndoOrRedo:) + name:NSUndoManagerDidUndoChangeNotification + object:[[self fieldEditor] undoManager]]; + // read the user default on if we should auto-complete the text field as the user // types or make them pick something from a list (a-la mozilla). mCompleteWhileTyping = [[NSUserDefaults standardUserDefaults] boolForKey:USER_DEFAULTS_AUTOCOMPLETE_WHILE_TYPING]; @@ -501,6 +510,11 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self resizePopup]; } +- (void) onUndoOrRedo:(NSNotification *)aNote +{ + [self clearResults]; +} + // NSTextField delegate ////////////////////////////////// - (void)controlTextDidChange:(NSNotification *)aNote {