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

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

Issue 289183002: Only allow editable textfields to consume backspace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | 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 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 ui::GetTextEditKeyBindingsDelegate(); 717 ui::GetTextEditKeyBindingsDelegate();
718 std::vector<ui::TextEditCommandAuraLinux> commands; 718 std::vector<ui::TextEditCommandAuraLinux> commands;
719 if (delegate && delegate->MatchEvent(event, &commands)) { 719 if (delegate && delegate->MatchEvent(event, &commands)) {
720 const bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT; 720 const bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT;
721 for (size_t i = 0; i < commands.size(); ++i) 721 for (size_t i = 0; i < commands.size(); ++i)
722 if (IsCommandIdEnabled(GetViewsCommand(commands[i], rtl))) 722 if (IsCommandIdEnabled(GetViewsCommand(commands[i], rtl)))
723 return true; 723 return true;
724 } 724 }
725 #endif 725 #endif
726 726
727 // Skip any accelerator handling of backspace; textfields handle this key. 727 // Skip backspace accelerator handling; editable textfields handle this key.
728 // Also skip processing Windows [Alt]+<num-pad digit> Unicode alt-codes. 728 // Also skip processing Windows [Alt]+<num-pad digit> Unicode alt-codes.
729 return event.key_code() == ui::VKEY_BACK || event.IsUnicodeKeyCode(); 729 const bool is_backspace = event.key_code() == ui::VKEY_BACK;
730 return (is_backspace && !read_only()) || event.IsUnicodeKeyCode();
730 } 731 }
731 732
732 bool Textfield::GetDropFormats( 733 bool Textfield::GetDropFormats(
733 int* formats, 734 int* formats,
734 std::set<OSExchangeData::CustomFormat>* custom_formats) { 735 std::set<OSExchangeData::CustomFormat>* custom_formats) {
735 if (!enabled() || read_only()) 736 if (!enabled() || read_only())
736 return false; 737 return false;
737 // TODO(msw): Can we support URL, FILENAME, etc.? 738 // TODO(msw): Can we support URL, FILENAME, etc.?
738 *formats = ui::OSExchangeData::STRING; 739 *formats = ui::OSExchangeData::STRING;
739 if (controller_) 740 if (controller_)
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 const size_t length = selection_clipboard_text.length(); 1681 const size_t length = selection_clipboard_text.length();
1681 range = gfx::Range(range.start() + length, range.end() + length); 1682 range = gfx::Range(range.start() + length, range.end() + length);
1682 } 1683 }
1683 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1684 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1684 UpdateAfterChange(true, true); 1685 UpdateAfterChange(true, true);
1685 OnAfterUserAction(); 1686 OnAfterUserAction();
1686 } 1687 }
1687 } 1688 }
1688 1689
1689 } // namespace views 1690 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698