| 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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 // We should only arrive here when the field is focussed. | 566 // We should only arrive here when the field is focussed. |
| 567 DCHECK(IsFirstResponder()); | 567 DCHECK(IsFirstResponder()); |
| 568 | 568 |
| 569 model_->OnEscapeKeyPressed(); | 569 model_->OnEscapeKeyPressed(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 void AutocompleteEditViewMac::OnWillBeginEditing() { | 572 void AutocompleteEditViewMac::OnWillBeginEditing() { |
| 573 // We should only arrive here when the field is focussed. | 573 // We should only arrive here when the field is focussed. |
| 574 DCHECK([field_ currentEditor]); | 574 DCHECK([field_ currentEditor]); |
| 575 | 575 |
| 576 // TODO(shess): Detect control-key situation. Since this code is | 576 NSEvent* theEvent = [NSApp currentEvent]; |
| 577 // called on first edit, not on receipt of focus, it may be that we | 577 const bool controlDown = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
| 578 // cannot correctly handle this without refactoring. | |
| 579 const bool controlDown = false; | |
| 580 model_->OnSetFocus(controlDown); | 578 model_->OnSetFocus(controlDown); |
| 581 | 579 |
| 582 // Capture the current state. | 580 // Capture the current state. |
| 583 OnBeforePossibleChange(); | 581 OnBeforePossibleChange(); |
| 584 } | 582 } |
| 585 | 583 |
| 586 void AutocompleteEditViewMac::OnDidEndEditing() { | 584 void AutocompleteEditViewMac::OnDidEndEditing() { |
| 587 ClosePopup(); | 585 ClosePopup(); |
| 588 | 586 |
| 589 // Tell the model to reset itself. | 587 // Tell the model to reset itself. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 | 838 |
| 841 // AutocompleteTextField adds a delegate method which allows us to | 839 // AutocompleteTextField adds a delegate method which allows us to |
| 842 // track -flagsChanged: calls. | 840 // track -flagsChanged: calls. |
| 843 // | 841 // |
| 844 // When the user types Control-Enter, the existing content has "www." | 842 // When the user types Control-Enter, the existing content has "www." |
| 845 // prepended and ".com" appended. This calls down to | 843 // prepended and ".com" appended. This calls down to |
| 846 // AutocompleteEditModel::OnControlKeyChanged() so that it can change | 844 // AutocompleteEditModel::OnControlKeyChanged() so that it can change |
| 847 // the popup to reflect this. See autocomplete_edit.cc | 845 // the popup to reflect this. See autocomplete_edit.cc |
| 848 // OnControlKeyChanged() and OnAfterPossibleChange(). | 846 // OnControlKeyChanged() and OnAfterPossibleChange(). |
| 849 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { | 847 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { |
| 850 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; | 848 bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; |
| 851 edit_view_->OnControlKeyChanged(controlFlag); | 849 edit_view_->OnControlKeyChanged(controlFlag); |
| 852 } | 850 } |
| 853 | 851 |
| 854 @end | 852 @end |
| OLD | NEW |