| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/textfield/native_textfield_win.h" | 5 #include "views/controls/textfield/native_textfield_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 textfield_->SyncText(); | 609 textfield_->SyncText(); |
| 610 return DefWindowProc(message, wparam, lparam); | 610 return DefWindowProc(message, wparam, lparam); |
| 611 } | 611 } |
| 612 | 612 |
| 613 void NativeTextfieldWin::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) { | 613 void NativeTextfieldWin::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) { |
| 614 // NOTE: Annoyingly, ctrl-alt-<key> generates WM_KEYDOWN rather than | 614 // NOTE: Annoyingly, ctrl-alt-<key> generates WM_KEYDOWN rather than |
| 615 // WM_SYSKEYDOWN, so we need to check (flags & KF_ALTDOWN) in various places | 615 // WM_SYSKEYDOWN, so we need to check (flags & KF_ALTDOWN) in various places |
| 616 // in this function even with a WM_SYSKEYDOWN handler. | 616 // in this function even with a WM_SYSKEYDOWN handler. |
| 617 | 617 |
| 618 switch (key) { | 618 switch (key) { |
| 619 |
| 620 // Ignore Return |
| 619 case VK_RETURN: | 621 case VK_RETURN: |
| 620 // If we are multi-line, we want to let returns through so they start a | 622 return; |
| 621 // new line. | 623 |
| 622 if (textfield_->IsMultiLine()) | |
| 623 break; | |
| 624 else | |
| 625 return; | |
| 626 // Hijacking Editing Commands | 624 // Hijacking Editing Commands |
| 627 // | 625 // |
| 628 // We hijack the keyboard short-cuts for Cut, Copy, and Paste here so that | 626 // We hijack the keyboard short-cuts for Cut, Copy, and Paste here so that |
| 629 // they go through our clipboard routines. This allows us to be smarter | 627 // they go through our clipboard routines. This allows us to be smarter |
| 630 // about how we interact with the clipboard and avoid bugs in the | 628 // about how we interact with the clipboard and avoid bugs in the |
| 631 // CRichEditCtrl. If we didn't hijack here, the edit control would handle | 629 // CRichEditCtrl. If we didn't hijack here, the edit control would handle |
| 632 // these internally with sending the WM_CUT, WM_COPY, or WM_PASTE messages. | 630 // these internally with sending the WM_CUT, WM_COPY, or WM_PASTE messages. |
| 633 // | 631 // |
| 634 // Cut: Shift-Delete and Ctrl-x are treated as cut. Ctrl-Shift-Delete and | 632 // Cut: Shift-Delete and Ctrl-x are treated as cut. Ctrl-Shift-Delete and |
| 635 // Ctrl-Shift-x are not treated as cut even though the underlying | 633 // Ctrl-Shift-x are not treated as cut even though the underlying |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1143 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| 1146 Textfield* field) { | 1144 Textfield* field) { |
| 1147 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { | 1145 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { |
| 1148 return new NativeTextfieldViews(field); | 1146 return new NativeTextfieldViews(field); |
| 1149 } else { | 1147 } else { |
| 1150 return new NativeTextfieldWin(field); | 1148 return new NativeTextfieldWin(field); |
| 1151 } | 1149 } |
| 1152 } | 1150 } |
| 1153 | 1151 |
| 1154 } // namespace views | 1152 } // namespace views |
| OLD | NEW |