OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/cocoa/autocomplete_text_field.h" | 5 #include "chrome/browser/cocoa/autocomplete_text_field.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h" | 8 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h" |
9 | 9 |
10 @implementation AutocompleteTextField | 10 @implementation AutocompleteTextField |
11 | 11 |
12 + (Class)cellClass { | 12 + (Class)cellClass { |
13 return [AutocompleteTextFieldCell class]; | 13 return [AutocompleteTextFieldCell class]; |
14 } | 14 } |
15 | 15 |
16 - (void)awakeFromNib { | 16 - (void)awakeFromNib { |
17 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); | 17 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); |
18 } | 18 } |
19 | 19 |
20 - (BOOL)textShouldPaste:(NSText*)fieldEditor { | 20 - (BOOL)textShouldPaste:(NSText*)fieldEditor { |
21 id delegate = [self delegate]; | 21 id delegate = [self delegate]; |
22 if ([delegate respondsToSelector:@selector(control:textShouldPaste:)]) { | 22 if ([delegate respondsToSelector:@selector(control:textShouldPaste:)]) { |
23 return [delegate control:self textShouldPaste:fieldEditor]; | 23 return [delegate control:self textShouldPaste:fieldEditor]; |
24 } | 24 } |
25 return YES; | 25 return YES; |
26 } | 26 } |
27 | 27 |
| 28 - (NSString*)textPasteActionString:(NSText*)fieldEditor { |
| 29 id delegate = [self delegate]; |
| 30 if ([delegate respondsToSelector:@selector(control:textPasteActionString:)]) { |
| 31 return [delegate control:self textPasteActionString:fieldEditor]; |
| 32 } |
| 33 return nil; |
| 34 } |
| 35 |
| 36 - (void)textDidPasteAndGo:(NSText*)fieldEditor { |
| 37 id delegate = [self delegate]; |
| 38 if ([delegate respondsToSelector:@selector(control:textDidPasteAndGo:)]) { |
| 39 [delegate control:self textDidPasteAndGo:fieldEditor]; |
| 40 } |
| 41 } |
| 42 |
28 - (void)flagsChanged:(NSEvent*)theEvent { | 43 - (void)flagsChanged:(NSEvent*)theEvent { |
29 id delegate = [self delegate]; | 44 id delegate = [self delegate]; |
30 if ([delegate respondsToSelector:@selector(control:flagsChanged:)]) { | 45 if ([delegate respondsToSelector:@selector(control:flagsChanged:)]) { |
31 [delegate control:self flagsChanged:theEvent]; | 46 [delegate control:self flagsChanged:theEvent]; |
32 } | 47 } |
33 [super flagsChanged:theEvent]; | 48 [super flagsChanged:theEvent]; |
34 } | 49 } |
35 | 50 |
36 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell { | 51 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell { |
37 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); | 52 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // field editor to the end of the content so that the selection | 160 // field editor to the end of the content so that the selection |
146 // doesn't initiate from somewhere in the middle of the text. | 161 // doesn't initiate from somewhere in the middle of the text. |
147 if (location.x > NSMaxX(textFrame)) { | 162 if (location.x > NSMaxX(textFrame)) { |
148 [editor scrollRangeToVisible:NSMakeRange([[self stringValue] length], 0)]; | 163 [editor scrollRangeToVisible:NSMakeRange([[self stringValue] length], 0)]; |
149 } | 164 } |
150 | 165 |
151 [editor mouseDown:theEvent]; | 166 [editor mouseDown:theEvent]; |
152 } | 167 } |
153 | 168 |
154 @end | 169 @end |
OLD | NEW |