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

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

Issue 2505943002: MacViews: Fix accelerator handling while Omnibox is in focus. (Closed)
Patch Set: Fix tapted's review issues. Created 4 years, 1 month 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 | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | 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 4b0bef22f724ba3c3d7bd4defe8aab6874b4560c..87de224d04ff051dbcf1d67b252365447ba35e87 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -64,6 +64,12 @@ namespace views {
namespace {
#if defined(OS_MACOSX)
+const ui::EventFlags kPlatformModifier = ui::EF_COMMAND_DOWN;
+#else
+const ui::EventFlags kPlatformModifier = ui::EF_CONTROL_DOWN;
+#endif // OS_MACOSX
+
+#if defined(OS_MACOSX)
const gfx::SelectionBehavior kLineSelectionBehavior = gfx::SELECTION_EXTEND;
const gfx::SelectionBehavior kWordSelectionBehavior = gfx::SELECTION_CARET;
const gfx::SelectionBehavior kMoveParagraphSelectionBehavior =
@@ -92,7 +98,7 @@ ui::TextEditCommand GetCommandForKeyEvent(const ui::KeyEvent& event) {
return ui::TextEditCommand::INVALID_COMMAND;
const bool shift = event.IsShiftDown();
- const bool control = event.IsControlDown();
+ const bool control = event.IsControlDown() || event.IsCommandDown();
Peter Kasting 2016/11/23 17:35:22 This doesn't need to check the specific platform m
tapted 2016/11/23 23:43:21 I think this is right, and it's the simplest thing
const bool alt = event.IsAltDown() || event.IsAltGrDown();
switch (event.key_code()) {
case ui::VKEY_Z:
@@ -1182,23 +1188,23 @@ bool Textfield::GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) const {
switch (command_id) {
case IDS_APP_UNDO:
- *accelerator = ui::Accelerator(ui::VKEY_Z, ui::EF_CONTROL_DOWN);
+ *accelerator = ui::Accelerator(ui::VKEY_Z, kPlatformModifier);
return true;
case IDS_APP_CUT:
- *accelerator = ui::Accelerator(ui::VKEY_X, ui::EF_CONTROL_DOWN);
+ *accelerator = ui::Accelerator(ui::VKEY_X, kPlatformModifier);
return true;
case IDS_APP_COPY:
- *accelerator = ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN);
+ *accelerator = ui::Accelerator(ui::VKEY_C, kPlatformModifier);
return true;
case IDS_APP_PASTE:
- *accelerator = ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN);
+ *accelerator = ui::Accelerator(ui::VKEY_V, kPlatformModifier);
return true;
case IDS_APP_SELECT_ALL:
- *accelerator = ui::Accelerator(ui::VKEY_A, ui::EF_CONTROL_DOWN);
+ *accelerator = ui::Accelerator(ui::VKEY_A, kPlatformModifier);
return true;
default:
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698