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

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

Issue 2342343003: views: provide feedback when editing fails (Closed)
Patch Set: OnEditFailed -> OnKeypressUnhandled Created 4 years, 3 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
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 } 678 }
679 #endif 679 #endif
680 680
681 if (edit_command == ui::TextEditCommand::INVALID_COMMAND) 681 if (edit_command == ui::TextEditCommand::INVALID_COMMAND)
682 edit_command = GetCommandForKeyEvent(event); 682 edit_command = GetCommandForKeyEvent(event);
683 683
684 if (!handled && IsTextEditCommandEnabled(edit_command)) { 684 if (!handled && IsTextEditCommandEnabled(edit_command)) {
685 ExecuteTextEditCommand(edit_command); 685 ExecuteTextEditCommand(edit_command);
686 handled = true; 686 handled = true;
687 } 687 }
688
689 if (!handled)
690 OnKeypressUnhandled();
688 return handled; 691 return handled;
689 } 692 }
690 693
691 bool Textfield::OnKeyReleased(const ui::KeyEvent& event) { 694 bool Textfield::OnKeyReleased(const ui::KeyEvent& event) {
692 return controller_ && controller_->HandleKeyEvent(this, event); 695 return controller_ && controller_->HandleKeyEvent(this, event);
693 } 696 }
694 697
695 void Textfield::OnGestureEvent(ui::GestureEvent* event) { 698 void Textfield::OnGestureEvent(ui::GestureEvent* event) {
696 switch (event->type()) { 699 switch (event->type()) {
697 case ui::ET_GESTURE_TAP_DOWN: 700 case ui::ET_GESTURE_TAP_DOWN:
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 1271
1269 OnBeforeUserAction(); 1272 OnBeforeUserAction();
1270 skip_input_method_cancel_composition_ = true; 1273 skip_input_method_cancel_composition_ = true;
1271 model_->InsertText(new_text); 1274 model_->InsertText(new_text);
1272 skip_input_method_cancel_composition_ = false; 1275 skip_input_method_cancel_composition_ = false;
1273 UpdateAfterChange(true, true); 1276 UpdateAfterChange(true, true);
1274 OnAfterUserAction(); 1277 OnAfterUserAction();
1275 } 1278 }
1276 1279
1277 void Textfield::InsertChar(const ui::KeyEvent& event) { 1280 void Textfield::InsertChar(const ui::KeyEvent& event) {
1281 if (read_only()) {
1282 OnKeypressUnhandled();
1283 return;
1284 }
1285
1278 // Filter out all control characters, including tab and new line characters, 1286 // Filter out all control characters, including tab and new line characters,
1279 // and all characters with Alt modifier (and Search on ChromeOS). But allow 1287 // and all characters with Alt modifier (and Search on ChromeOS). But allow
1280 // characters with the AltGr modifier. On Windows AltGr is represented by 1288 // characters with the AltGr modifier. On Windows AltGr is represented by
1281 // Alt+Ctrl or Right Alt, and on Linux it's a different flag that we don't 1289 // Alt+Ctrl or Right Alt, and on Linux it's a different flag that we don't
1282 // care about. 1290 // care about.
1283 const base::char16 ch = event.GetCharacter(); 1291 const base::char16 ch = event.GetCharacter();
1284 const bool should_insert_char = ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && 1292 const bool should_insert_char = ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
1285 !ui::IsSystemKeyModifier(event.flags()); 1293 !ui::IsSystemKeyModifier(event.flags());
1286 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char) 1294 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char)
1287 return; 1295 return;
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 if (!HasFocus()) 2034 if (!HasFocus())
2027 RequestFocus(); 2035 RequestFocus();
2028 model_->MoveCursorTo(mouse); 2036 model_->MoveCursorTo(mouse);
2029 if (!selection_clipboard_text.empty()) { 2037 if (!selection_clipboard_text.empty()) {
2030 model_->InsertText(selection_clipboard_text); 2038 model_->InsertText(selection_clipboard_text);
2031 UpdateAfterChange(true, true); 2039 UpdateAfterChange(true, true);
2032 } 2040 }
2033 OnAfterUserAction(); 2041 OnAfterUserAction();
2034 } 2042 }
2035 2043
2044 void Textfield::OnKeypressUnhandled() {
2045 PlatformStyle::OnTextfieldKeypressUnhandled();
2046 }
2047
2036 } // namespace views 2048 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698