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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 307783003: Fix Textfield::OnKeyPressed command handling for Linux Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 0202b0fd694e1a11047a0258897dca591fa599de..f4d6a0f7630afcef34bb6426f587561785892df5 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -75,6 +75,7 @@ int GetDragSelectionDelay() {
return 100;
}
+// Get the default command for a given key |event| and selection state.
int GetCommandForKeyEvent(const ui::KeyEvent& event, bool has_selection) {
if (event.type() != ui::ET_KEY_PRESSED || event.IsUnicodeKeyCode())
return kNoCommand;
@@ -147,6 +148,7 @@ int GetCommandForKeyEvent(const ui::KeyEvent& event, bool has_selection) {
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// Convert a custom text edit |command| to the equivalent views command ID.
int GetViewsCommand(const ui::TextEditCommandAuraLinux& command, bool rtl) {
const bool select = command.extend_selection();
switch (command.command_id()) {
@@ -600,19 +602,15 @@ void Textfield::OnMouseReleased(const ui::MouseEvent& event) {
bool Textfield::OnKeyPressed(const ui::KeyEvent& event) {
bool handled = controller_ && controller_->HandleKeyEvent(this, event);
- if (handled)
- return true;
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
ui::TextEditKeyBindingsDelegateAuraLinux* delegate =
ui::GetTextEditKeyBindingsDelegate();
std::vector<ui::TextEditCommandAuraLinux> commands;
- if (delegate) {
- if (!delegate->MatchEvent(event, &commands))
- return false;
+ if (!handled && delegate && delegate->MatchEvent(event, &commands)) {
const bool rtl = GetTextDirection() == base::i18n::RIGHT_TO_LEFT;
for (size_t i = 0; i < commands.size(); ++i) {
- int command = GetViewsCommand(commands[i], rtl);
+ const int command = GetViewsCommand(commands[i], rtl);
if (IsCommandIdEnabled(command)) {
ExecuteCommand(command);
handled = true;
@@ -623,11 +621,11 @@ bool Textfield::OnKeyPressed(const ui::KeyEvent& event) {
#endif
const int command = GetCommandForKeyEvent(event, HasSelection());
- if (IsCommandIdEnabled(command)) {
+ if (!handled && IsCommandIdEnabled(command)) {
ExecuteCommand(command);
- return true;
+ handled = true;
}
- return false;
+ return handled;
}
ui::TextInputClient* Textfield::GetTextInputClient() {
« 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