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 "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 "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" |
11 #include "app/keyboard_codes.h" | 11 #include "app/keyboard_codes.h" |
| 12 #include "app/keyboard_code_conversion_win.h" |
12 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
13 #include "app/l10n_util_win.h" | 14 #include "app/l10n_util_win.h" |
14 #include "app/win/win_util.h" | 15 #include "app/win/win_util.h" |
15 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
18 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
19 #include "gfx/native_theme_win.h" | 20 #include "gfx/native_theme_win.h" |
20 #include "grit/app_strings.h" | 21 #include "grit/app_strings.h" |
21 #include "skia/ext/skia_utils_win.h" | 22 #include "skia/ext/skia_utils_win.h" |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 | 870 |
870 void NativeTextfieldWin::HandleKeystroke(UINT message, | 871 void NativeTextfieldWin::HandleKeystroke(UINT message, |
871 TCHAR key, | 872 TCHAR key, |
872 UINT repeat_count, | 873 UINT repeat_count, |
873 UINT flags) { | 874 UINT flags) { |
874 ScopedFreeze freeze(this, GetTextObjectModel()); | 875 ScopedFreeze freeze(this, GetTextObjectModel()); |
875 | 876 |
876 Textfield::Controller* controller = textfield_->GetController(); | 877 Textfield::Controller* controller = textfield_->GetController(); |
877 bool handled = false; | 878 bool handled = false; |
878 if (controller) { | 879 if (controller) { |
879 handled = controller->HandleKeystroke(textfield_, | 880 Event::EventType type; |
880 Textfield::Keystroke(message, key, repeat_count, flags)); | 881 switch (message) { |
| 882 case WM_KEYDOWN: |
| 883 case WM_CHAR: |
| 884 type = Event::ET_KEY_PRESSED; |
| 885 break; |
| 886 case WM_KEYUP: |
| 887 type = Event::ET_KEY_RELEASED; |
| 888 break; |
| 889 default: |
| 890 NOTREACHED() << "Unknown message:" << message; |
| 891 // Passing through to avoid crash on release build. |
| 892 type = Event::ET_KEY_PRESSED; |
| 893 } |
| 894 KeyEvent key_event(type, |
| 895 app::KeyboardCodeForWindowsKeyCode(key), |
| 896 KeyEvent::GetKeyStateFlags(), |
| 897 repeat_count, |
| 898 flags, |
| 899 message); |
| 900 handled = controller->HandleKeyEvent(textfield_, key_event); |
881 } | 901 } |
882 | 902 |
883 if (!handled) { | 903 if (!handled) { |
884 OnBeforePossibleChange(); | 904 OnBeforePossibleChange(); |
885 | 905 |
886 if (key == app::VKEY_HOME || key == app::VKEY_END) { | 906 if (key == app::VKEY_HOME || key == app::VKEY_END) { |
887 // DefWindowProc() might reset the keyboard layout when it receives a | 907 // DefWindowProc() might reset the keyboard layout when it receives a |
888 // keydown event for VKEY_HOME or VKEY_END. When the window was created | 908 // keydown event for VKEY_HOME or VKEY_END. When the window was created |
889 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, | 909 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, |
890 // if the input text is pure LTR text, the layout changes to the first RTL | 910 // if the input text is pure LTR text, the layout changes to the first RTL |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 //////////////////////////////////////////////////////////////////////////////// | 1092 //////////////////////////////////////////////////////////////////////////////// |
1073 // NativeTextfieldWrapper, public: | 1093 // NativeTextfieldWrapper, public: |
1074 | 1094 |
1075 // static | 1095 // static |
1076 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1096 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
1077 Textfield* field) { | 1097 Textfield* field) { |
1078 return new NativeTextfieldWin(field); | 1098 return new NativeTextfieldWin(field); |
1079 } | 1099 } |
1080 | 1100 |
1081 } // namespace views | 1101 } // namespace views |
OLD | NEW |