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/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 const int count = by_page ? model_->result().size() : 1; | 436 const int count = by_page ? model_->result().size() : 1; |
437 model_->OnUpOrDownKeyPressed(up ? -count : count); | 437 model_->OnUpOrDownKeyPressed(up ? -count : count); |
438 } | 438 } |
439 void AutocompleteEditViewMac::OnEscapeKeyPressed() { | 439 void AutocompleteEditViewMac::OnEscapeKeyPressed() { |
440 model_->OnEscapeKeyPressed(); | 440 model_->OnEscapeKeyPressed(); |
441 } | 441 } |
442 void AutocompleteEditViewMac::OnSetFocus(bool f) { | 442 void AutocompleteEditViewMac::OnSetFocus(bool f) { |
443 model_->OnSetFocus(f); | 443 model_->OnSetFocus(f); |
444 } | 444 } |
445 void AutocompleteEditViewMac::OnKillFocus() { | 445 void AutocompleteEditViewMac::OnKillFocus() { |
| 446 // TODO(shess): This would seem to be a job for |model_|. |
| 447 ClosePopup(); |
| 448 |
| 449 // Tell the model to reset itself. |
446 model_->OnKillFocus(); | 450 model_->OnKillFocus(); |
447 } | 451 } |
448 void AutocompleteEditViewMac::AcceptInput( | 452 void AutocompleteEditViewMac::AcceptInput( |
449 WindowOpenDisposition disposition, bool for_drop) { | 453 WindowOpenDisposition disposition, bool for_drop) { |
450 model_->AcceptInput(disposition, for_drop); | 454 model_->AcceptInput(disposition, for_drop); |
451 } | 455 } |
452 | 456 |
453 void AutocompleteEditViewMac::FocusLocation() { | 457 void AutocompleteEditViewMac::FocusLocation() { |
454 // -makeFirstResponder: will select the entire field_. If we're | 458 // -makeFirstResponder: will select the entire field_. If we're |
455 // already firstResponder, it's likely that we want to retain the | 459 // already firstResponder, it's likely that we want to retain the |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 } | 521 } |
518 | 522 |
519 - (void)controlTextDidChange:(NSNotification*)aNotification { | 523 - (void)controlTextDidChange:(NSNotification*)aNotification { |
520 // Figure out what changed and notify the model_. | 524 // Figure out what changed and notify the model_. |
521 edit_view_->OnAfterPossibleChange(); | 525 edit_view_->OnAfterPossibleChange(); |
522 | 526 |
523 // Then capture the new state. | 527 // Then capture the new state. |
524 edit_view_->OnBeforePossibleChange(); | 528 edit_view_->OnBeforePossibleChange(); |
525 } | 529 } |
526 | 530 |
527 - (void)controlTextDidEndEditing:(NSNotification*)aNotification { | 531 - (BOOL)control:(NSControl*)control textShouldEndEditing:(NSText*)fieldEditor { |
528 edit_view_->OnKillFocus(); | 532 edit_view_->OnKillFocus(); |
529 | 533 |
| 534 return YES; |
| 535 |
530 // TODO(shess): Figure out where the selection belongs. On GTK, | 536 // TODO(shess): Figure out where the selection belongs. On GTK, |
531 // it's set to the start of the text. | 537 // it's set to the start of the text. |
532 } | 538 } |
533 | 539 |
534 @end | 540 @end |
OLD | NEW |