OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 8 |
9 #include "app/clipboard/clipboard.h" | 9 #include "app/clipboard/clipboard.h" |
10 #include "app/clipboard/scoped_clipboard_writer.h" | 10 #include "app/clipboard/scoped_clipboard_writer.h" |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 else | 471 else |
472 SetSelectedRange(NSMakeRange([text length] - suggest_text_length_, 0)); | 472 SetSelectedRange(NSMakeRange([text length] - suggest_text_length_, 0)); |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 bool AutocompleteEditViewMac::CommitSuggestText() { | 476 bool AutocompleteEditViewMac::CommitSuggestText() { |
477 if (suggest_text_length_ == 0) | 477 if (suggest_text_length_ == 0) |
478 return false; | 478 return false; |
479 | 479 |
480 suggest_text_length_ = 0; | 480 suggest_text_length_ = 0; |
481 // Call SetText() to force a redraw and move the cursor to the end. | |
482 SetText(GetText()); | |
481 model()->FinalizeInstantQuery(GetText()); | 483 model()->FinalizeInstantQuery(GetText()); |
482 return true; | 484 return true; |
483 } | 485 } |
484 | 486 |
485 void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { | 487 void AutocompleteEditViewMac::SetText(const std::wstring& display_text) { |
486 // If we are setting the text directly, there cannot be any suggest text. | 488 // If we are setting the text directly, there cannot be any suggest text. |
487 suggest_text_length_ = 0; | 489 suggest_text_length_ = 0; |
488 SetTextInternal(display_text); | 490 SetTextInternal(display_text); |
489 } | 491 } |
490 | 492 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 } | 766 } |
765 | 767 |
766 if (cmd == @selector(moveRight:)) { | 768 if (cmd == @selector(moveRight:)) { |
767 // Only commit suggested text if the cursor is all the way to the right and | 769 // Only commit suggested text if the cursor is all the way to the right and |
768 // there is no selection. | 770 // there is no selection. |
769 NSRange range = GetSelectedRange(); | 771 NSRange range = GetSelectedRange(); |
770 if (range.length == 0 && | 772 if (range.length == 0 && |
771 suggest_text_length_ > 0 && | 773 suggest_text_length_ > 0 && |
772 (range.location + suggest_text_length_ == | 774 (range.location + suggest_text_length_ == |
773 [[field_ stringValue] length])) { | 775 [[field_ stringValue] length])) { |
776 LOG(ERROR) << "Committing suggest"; | |
Nico
2010/12/06 04:07:51
remove?
rohitrao (ping after 24h)
2010/12/06 19:46:29
Silly log spam. Gone.
| |
774 controller_->OnCommitSuggestedText(GetText()); | 777 controller_->OnCommitSuggestedText(GetText()); |
775 return true; | 778 return true; |
776 } | 779 } |
777 } | 780 } |
778 | 781 |
779 if (cmd == @selector(scrollPageDown:)) { | 782 if (cmd == @selector(scrollPageDown:)) { |
780 model_->OnUpOrDownKeyPressed(model_->result().size()); | 783 model_->OnUpOrDownKeyPressed(model_->result().size()); |
781 return true; | 784 return true; |
782 } | 785 } |
783 | 786 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 } | 1071 } |
1069 | 1072 |
1070 return std::wstring(); | 1073 return std::wstring(); |
1071 } | 1074 } |
1072 | 1075 |
1073 // static | 1076 // static |
1074 NSFont* AutocompleteEditViewMac::GetFieldFont() { | 1077 NSFont* AutocompleteEditViewMac::GetFieldFont() { |
1075 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1078 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1076 return rb.GetFont(ResourceBundle::BaseFont).GetNativeFont(); | 1079 return rb.GetFont(ResourceBundle::BaseFont).GetNativeFont(); |
1077 } | 1080 } |
OLD | NEW |