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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/find_bar_controller.h" | 9 #include "chrome/browser/find_bar_controller.h" |
10 #include "chrome/browser/cocoa/browser_window_cocoa.h" | 10 #include "chrome/browser/cocoa/browser_window_cocoa.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 [self updateUIForFindResult:tab_contents->find_result() | 140 [self updateUIForFindResult:tab_contents->find_result() |
141 withText:string16()]; | 141 withText:string16()]; |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 // NSControl delegate method | 145 // NSControl delegate method |
146 - (BOOL)control:(NSControl*)control | 146 - (BOOL)control:(NSControl*)control |
147 textView:(NSTextView*)textView | 147 textView:(NSTextView*)textView |
148 doCommandBySelector:(SEL)command { | 148 doCommandBySelector:(SEL)command { |
149 if (command == @selector(insertNewline:)) { | 149 if (command == @selector(insertNewline:)) { |
| 150 // Pressing Return |
150 NSEvent* event = [NSApp currentEvent]; | 151 NSEvent* event = [NSApp currentEvent]; |
151 | 152 |
152 if ([event modifierFlags] & NSShiftKeyMask) | 153 if ([event modifierFlags] & NSShiftKeyMask) |
153 [previousButton_ performClick:nil]; | 154 [previousButton_ performClick:nil]; |
154 else | 155 else |
155 [nextButton_ performClick:nil]; | 156 [nextButton_ performClick:nil]; |
156 | 157 |
157 return YES; | 158 return YES; |
| 159 } else if (command == @selector(insertLineBreak:)) { |
| 160 // Pressing Ctrl-Return |
| 161 if (findBarBridge_) { |
| 162 findBarBridge_->GetFindBarController()->EndFindSession( |
| 163 FindBarController::kActivateSelection); |
| 164 } |
| 165 return YES; |
158 } else if (command == @selector(pageUp:) || | 166 } else if (command == @selector(pageUp:) || |
159 command == @selector(pageUpAndModifySelection:) || | 167 command == @selector(pageUpAndModifySelection:) || |
160 command == @selector(scrollPageUp:) || | 168 command == @selector(scrollPageUp:) || |
161 command == @selector(pageDown:) || | 169 command == @selector(pageDown:) || |
162 command == @selector(pageDownAndModifySelection:) || | 170 command == @selector(pageDownAndModifySelection:) || |
163 command == @selector(scrollPageDown:) || | 171 command == @selector(scrollPageDown:) || |
164 command == @selector(scrollToBeginningOfDocument:) || | 172 command == @selector(scrollToBeginningOfDocument:) || |
165 command == @selector(scrollToEndOfDocument:) || | 173 command == @selector(scrollToEndOfDocument:) || |
166 command == @selector(moveUp:) || | 174 command == @selector(moveUp:) || |
167 command == @selector(moveDown:)) { | 175 command == @selector(moveDown:)) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // restore focus to the tab contents. | 292 // restore focus to the tab contents. |
285 if (result.number_of_matches() > 0) | 293 if (result.number_of_matches() > 0) |
286 focusTracker_.reset(nil); | 294 focusTracker_.reset(nil); |
287 } | 295 } |
288 | 296 |
289 - (BOOL)isFindBarVisible { | 297 - (BOOL)isFindBarVisible { |
290 // Find bar is visible if any part of it is on the screen. | 298 // Find bar is visible if any part of it is on the screen. |
291 return NSIntersectsRect([[self view] bounds], [findBarView_ frame]); | 299 return NSIntersectsRect([[self view] bounds], [findBarView_ frame]); |
292 } | 300 } |
293 | 301 |
| 302 - (BOOL)isFindBarAnimating { |
| 303 return (currentAnimation_.get() != nil); |
| 304 } |
| 305 |
294 // NSAnimation delegate methods. | 306 // NSAnimation delegate methods. |
295 - (void)animationDidEnd:(NSAnimation*)animation { | 307 - (void)animationDidEnd:(NSAnimation*)animation { |
296 // Autorelease the animation (cannot use release because the animation object | 308 // Autorelease the animation (cannot use release because the animation object |
297 // is still on the stack. | 309 // is still on the stack. |
298 DCHECK(animation == currentAnimation_.get()); | 310 DCHECK(animation == currentAnimation_.get()); |
299 [currentAnimation_.release() autorelease]; | 311 [currentAnimation_.release() autorelease]; |
300 | 312 |
301 // If the find bar is not visible, make it actually hidden, so it'll no longer | 313 // If the find bar is not visible, make it actually hidden, so it'll no longer |
302 // respond to key events. | 314 // respond to key events. |
303 [findBarView_ setHidden:![self isFindBarVisible]]; | 315 [findBarView_ setHidden:![self isFindBarVisible]]; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 375 } |
364 } | 376 } |
365 | 377 |
366 // Has to happen after |ClearResults()| above. | 378 // Has to happen after |ClearResults()| above. |
367 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; | 379 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; |
368 [previousButton_ setEnabled:buttonsEnabled]; | 380 [previousButton_ setEnabled:buttonsEnabled]; |
369 [nextButton_ setEnabled:buttonsEnabled]; | 381 [nextButton_ setEnabled:buttonsEnabled]; |
370 } | 382 } |
371 | 383 |
372 @end | 384 @end |
OLD | NEW |