| 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/clipboard.h" | 7 #include "base/clipboard.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 10 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 // OnAfterPossibleChange(), even if identical contents are pasted into the | 572 // OnAfterPossibleChange(), even if identical contents are pasted into the |
| 573 // text box. | 573 // text box. |
| 574 text_before_change_.clear(); | 574 text_before_change_.clear(); |
| 575 | 575 |
| 576 NSString* s = base::SysWideToNSString(text); | 576 NSString* s = base::SysWideToNSString(text); |
| 577 [[field_ currentEditor] replaceCharactersInRange:selectedRange withString:s]; | 577 [[field_ currentEditor] replaceCharactersInRange:selectedRange withString:s]; |
| 578 | 578 |
| 579 OnAfterPossibleChange(); | 579 OnAfterPossibleChange(); |
| 580 } | 580 } |
| 581 | 581 |
| 582 bool AutocompleteEditViewMac::IsPopupOpen() const { |
| 583 return popup_view_->IsOpen(); |
| 584 } |
| 585 |
| 582 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { | 586 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { |
| 583 model_->OnControlKeyChanged(pressed); | 587 model_->OnControlKeyChanged(pressed); |
| 584 } | 588 } |
| 585 | 589 |
| 586 void AutocompleteEditViewMac::AcceptInput( | 590 void AutocompleteEditViewMac::AcceptInput( |
| 587 WindowOpenDisposition disposition, bool for_drop) { | 591 WindowOpenDisposition disposition, bool for_drop) { |
| 588 model_->AcceptInput(disposition, for_drop); | 592 model_->AcceptInput(disposition, for_drop); |
| 589 } | 593 } |
| 590 | 594 |
| 591 void AutocompleteEditViewMac::FocusLocation() { | 595 void AutocompleteEditViewMac::FocusLocation() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 - initWithEditView:(AutocompleteEditViewMac*)view { | 642 - initWithEditView:(AutocompleteEditViewMac*)view { |
| 639 self = [super init]; | 643 self = [super init]; |
| 640 if (self) { | 644 if (self) { |
| 641 edit_view_ = view; | 645 edit_view_ = view; |
| 642 } | 646 } |
| 643 return self; | 647 return self; |
| 644 } | 648 } |
| 645 | 649 |
| 646 - (BOOL)control:(NSControl*)control | 650 - (BOOL)control:(NSControl*)control |
| 647 textView:(NSTextView*)textView doCommandBySelector:(SEL)cmd { | 651 textView:(NSTextView*)textView doCommandBySelector:(SEL)cmd { |
| 648 if (cmd == @selector(moveDown:)) { | 652 // Don't intercept up/down-arrow if the popup isn't open. |
| 649 edit_view_->OnUpOrDownKeyPressed(false, false); | 653 if (edit_view_->IsPopupOpen()) { |
| 650 return YES; | 654 if (cmd == @selector(moveDown:)) { |
| 651 } | 655 edit_view_->OnUpOrDownKeyPressed(false, false); |
| 652 | 656 return YES; |
| 653 if (cmd == @selector(moveUp:)) { | 657 } |
| 654 edit_view_->OnUpOrDownKeyPressed(true, false); | 658 |
| 655 return YES; | 659 if (cmd == @selector(moveUp:)) { |
| 660 edit_view_->OnUpOrDownKeyPressed(true, false); |
| 661 return YES; |
| 662 } |
| 656 } | 663 } |
| 657 | 664 |
| 658 if (cmd == @selector(scrollPageDown:)) { | 665 if (cmd == @selector(scrollPageDown:)) { |
| 659 edit_view_->OnUpOrDownKeyPressed(false, true); | 666 edit_view_->OnUpOrDownKeyPressed(false, true); |
| 660 return YES; | 667 return YES; |
| 661 } | 668 } |
| 662 | 669 |
| 663 if (cmd == @selector(scrollPageUp:)) { | 670 if (cmd == @selector(scrollPageUp:)) { |
| 664 edit_view_->OnUpOrDownKeyPressed(true, true); | 671 edit_view_->OnUpOrDownKeyPressed(true, true); |
| 665 return YES; | 672 return YES; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 // prepended and ".com" appended. This calls down to | 741 // prepended and ".com" appended. This calls down to |
| 735 // AutocompleteEditModel::OnControlKeyChanged() so that it can change | 742 // AutocompleteEditModel::OnControlKeyChanged() so that it can change |
| 736 // the popup to reflect this. See autocomplete_edit.cc | 743 // the popup to reflect this. See autocomplete_edit.cc |
| 737 // OnControlKeyChanged() and OnAfterPossibleChange(). | 744 // OnControlKeyChanged() and OnAfterPossibleChange(). |
| 738 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { | 745 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { |
| 739 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; | 746 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
| 740 edit_view_->OnControlKeyChanged(controlFlag); | 747 edit_view_->OnControlKeyChanged(controlFlag); |
| 741 } | 748 } |
| 742 | 749 |
| 743 @end | 750 @end |
| OLD | NEW |