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 <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/clipboard.h" | 10 #include "base/clipboard.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 // We're showing a keyword and the user pressed backspace at the | 646 // We're showing a keyword and the user pressed backspace at the |
647 // beginning of the text. Delete the selected keyword. | 647 // beginning of the text. Delete the selected keyword. |
648 model_->ClearKeyword(GetText()); | 648 model_->ClearKeyword(GetText()); |
649 return true; | 649 return true; |
650 } | 650 } |
651 | 651 |
652 bool AutocompleteEditViewMac::IsPopupOpen() const { | 652 bool AutocompleteEditViewMac::IsPopupOpen() const { |
653 return popup_view_->IsOpen(); | 653 return popup_view_->IsOpen(); |
654 } | 654 } |
655 | 655 |
| 656 void AutocompleteEditViewMac::TryDeletingCurrentItem() { |
| 657 popup_view_->GetModel()->TryDeletingCurrentItem(); |
| 658 } |
| 659 |
656 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { | 660 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { |
657 model_->OnControlKeyChanged(pressed); | 661 model_->OnControlKeyChanged(pressed); |
658 } | 662 } |
659 | 663 |
660 void AutocompleteEditViewMac::AcceptInput( | 664 void AutocompleteEditViewMac::AcceptInput( |
661 WindowOpenDisposition disposition, bool for_drop) { | 665 WindowOpenDisposition disposition, bool for_drop) { |
662 model_->AcceptInput(disposition, for_drop); | 666 model_->AcceptInput(disposition, for_drop); |
663 } | 667 } |
664 | 668 |
665 void AutocompleteEditViewMac::FocusLocation() { | 669 void AutocompleteEditViewMac::FocusLocation() { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 edit_view_->AcceptInput(disposition, false); | 779 edit_view_->AcceptInput(disposition, false); |
776 return YES; | 780 return YES; |
777 } | 781 } |
778 | 782 |
779 if (cmd == @selector(deleteBackward:)) { | 783 if (cmd == @selector(deleteBackward:)) { |
780 if (edit_view_->OnBackspacePressed()) { | 784 if (edit_view_->OnBackspacePressed()) { |
781 return YES; | 785 return YES; |
782 } | 786 } |
783 } | 787 } |
784 | 788 |
| 789 if (cmd == @selector(deleteForward:)) { |
| 790 const NSUInteger modifiers = [[NSApp currentEvent] modifierFlags]; |
| 791 if ((modifiers & NSShiftKeyMask) != 0) { |
| 792 if (edit_view_->IsPopupOpen()) { |
| 793 edit_view_->TryDeletingCurrentItem(); |
| 794 return YES; |
| 795 } |
| 796 } |
| 797 } |
| 798 |
785 // Capture the state before the operation changes the content. | 799 // Capture the state before the operation changes the content. |
786 // TODO(shess): Determine if this is always redundent WRT the call | 800 // TODO(shess): Determine if this is always redundent WRT the call |
787 // in -controlTextDidChange:. | 801 // in -controlTextDidChange:. |
788 edit_view_->OnBeforePossibleChange(); | 802 edit_view_->OnBeforePossibleChange(); |
789 return NO; | 803 return NO; |
790 } | 804 } |
791 | 805 |
792 - (void)controlTextDidBeginEditing:(NSNotification*)aNotification { | 806 - (void)controlTextDidBeginEditing:(NSNotification*)aNotification { |
793 edit_view_->OnWillBeginEditing(); | 807 edit_view_->OnWillBeginEditing(); |
794 } | 808 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 // prepended and ".com" appended. This calls down to | 845 // prepended and ".com" appended. This calls down to |
832 // AutocompleteEditModel::OnControlKeyChanged() so that it can change | 846 // AutocompleteEditModel::OnControlKeyChanged() so that it can change |
833 // the popup to reflect this. See autocomplete_edit.cc | 847 // the popup to reflect this. See autocomplete_edit.cc |
834 // OnControlKeyChanged() and OnAfterPossibleChange(). | 848 // OnControlKeyChanged() and OnAfterPossibleChange(). |
835 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { | 849 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { |
836 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; | 850 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
837 edit_view_->OnControlKeyChanged(controlFlag); | 851 edit_view_->OnControlKeyChanged(controlFlag); |
838 } | 852 } |
839 | 853 |
840 @end | 854 @end |
OLD | NEW |