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

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 866983006: MacViews: Intercept events for Menus (after AppKit has turned them into action messages). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150127-MacViews-SendTextfieldToWindow-TEXTFIELD
Patch Set: better IME handling Created 5 years, 10 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 | « ui/views/controls/menu/menu_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_controller.cc
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index d1547c41a8c3d4aaec0de657a595a2777328e742..b74ddce7d065ec711ec7e68fcc05f2f086196c8f 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -804,6 +804,22 @@ void MenuController::OnDragComplete(bool should_close) {
}
}
+ui::PostDispatchAction MenuController::OnWillDispatchKeyEvent(
+ base::char16 character,
+ ui::KeyboardCode key_code) {
+ if (exit_type() == MenuController::EXIT_ALL ||
+ exit_type() == MenuController::EXIT_DESTROYED) {
+ TerminateNestedMessageLoop();
+ return ui::POST_DISPATCH_PERFORM_DEFAULT;
+ }
+
+ bool should_quit = character ? SelectByChar(character) : !OnKeyDown(key_code);
+ if (should_quit || exit_type() != MenuController::EXIT_NONE)
+ TerminateNestedMessageLoop();
+
+ return ui::POST_DISPATCH_NONE;
+}
tapted 2015/02/04 11:55:48 This function started life being refactored out of
+
void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
if (submenu->IsShowing()) {
gfx::Point point = GetScreen()->GetCursorScreenPoint();
@@ -1028,16 +1044,22 @@ bool MenuController::OnKeyDown(ui::KeyboardCode key_code) {
CloseSubmenu();
break;
+// On Mac, treat space the same as return.
+#if !defined(OS_MACOSX)
case ui::VKEY_SPACE:
if (SendAcceleratorToHotTrackedView() == ACCELERATOR_PROCESSED_EXIT)
return false;
break;
+#endif
case ui::VKEY_F4:
if (!is_combobox_)
break;
// Fallthrough to accept or dismiss combobox menus on F4, like windows.
case ui::VKEY_RETURN:
+#if defined(OS_MACOSX)
+ case ui::VKEY_SPACE:
+#endif
if (pending_state_.item) {
if (pending_state_.item->HasSubmenu()) {
if (key_code == ui::VKEY_F4 &&
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698