Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: views/controls/textfield/native_textfield_win.cc

Issue 6034002: Replace Textfield::Keystroke with views::KeyEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 type = Event::ET_KEY_PRESSED;
884 break;
885 case WM_KEYUP:
886 type = Event::ET_KEY_RELEASED;
887 break;
888 case WM_CHAR:
889 type = Event::ET_UNKNOWN;
oshima 2011/01/04 20:26:34 I need your advice here. Event::EventType does not
Ben Goodger (Google) 2011/01/05 17:35:12 According to SDK docs, WM_CHAR is synthesized when
890 break;
891 default:
892 NOTREACHED() << "Unknown message:" << message;
893 // pass through to avoid crash on release build.
894 type = Event::ET_KEY_PRESSED;
895 }
896 KeyEvent key_event(type,
897 app::KeyboardCodeForWindowsKeyCode(key),
898 KeyEvent::GetKeyStateFlags(),
899 repeat_count,
900 flags,
901 message);
902 handled = controller->HandleKeyEvent(textfield_, key_event);
881 } 903 }
882 904
883 if (!handled) { 905 if (!handled) {
884 OnBeforePossibleChange(); 906 OnBeforePossibleChange();
885 907
886 if (key == app::VKEY_HOME || key == app::VKEY_END) { 908 if (key == app::VKEY_HOME || key == app::VKEY_END) {
887 // DefWindowProc() might reset the keyboard layout when it receives a 909 // DefWindowProc() might reset the keyboard layout when it receives a
888 // keydown event for VKEY_HOME or VKEY_END. When the window was created 910 // 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, 911 // 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 912 // 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
1072 //////////////////////////////////////////////////////////////////////////////// 1094 ////////////////////////////////////////////////////////////////////////////////
1073 // NativeTextfieldWrapper, public: 1095 // NativeTextfieldWrapper, public:
1074 1096
1075 // static 1097 // static
1076 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1098 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1077 Textfield* field) { 1099 Textfield* field) {
1078 return new NativeTextfieldWin(field); 1100 return new NativeTextfieldWin(field);
1079 } 1101 }
1080 1102
1081 } // namespace views 1103 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698