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

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

Issue 809773006: MacViews: Intercept events for Menus (after AppKit has interpreted keystrokes) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20141205-MacViews-AcceleratedWidget-PLUS-AddingLayers-fromcl-PLUS-bringup
Patch Set: rollback card unmask Created 6 years 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
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 5ecf6917260f09baabd3e35d91fef24ce4c09f93..d936f69689fddd9c4cd13e76afc61076c0086ea2 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -12,6 +12,7 @@
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
+#include "ui/events/keycodes/keyboard_code_conversion.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
@@ -800,6 +801,54 @@ void MenuController::OnDragComplete(bool should_close) {
}
}
+ui::PostDispatchAction MenuController::OnWillDispatchEvent(
+ const ui::Event& event) {
+ if (exit_type() == MenuController::EXIT_ALL ||
+ exit_type() == MenuController::EXIT_DESTROYED) {
+ TerminateNestedMessageLoop();
+ return ui::POST_DISPATCH_PERFORM_DEFAULT;
+ }
+
+ bool should_quit = false;
+ bool should_perform_default = true;
+ switch (event.type()) {
+ case ui::ET_KEY_PRESSED: {
+ const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event);
+ if (!OnKeyDown(key_event.key_code())) {
+ should_quit = true;
+ should_perform_default = false;
+ break;
+ }
+
+ // Do not check mnemonics if the Alt or Ctrl modifiers are pressed.
+ int flags = key_event.flags();
+ if ((flags & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)) == 0) {
+ char c = ui::GetCharacterFromKeyCode(key_event.key_code(), flags);
+ if (SelectByChar(c)) {
+ should_quit = true;
+ should_perform_default = false;
+ break;
+ }
+ }
+ should_quit = false;
+ should_perform_default = false;
+ break;
+ }
+ case ui::ET_KEY_RELEASED:
+ should_quit = false;
+ should_perform_default = false;
+ break;
+ default:
+ break;
+ }
+
+ if (should_quit || exit_type() != MenuController::EXIT_NONE)
+ TerminateNestedMessageLoop();
+
+ return should_perform_default ? ui::POST_DISPATCH_PERFORM_DEFAULT
+ : ui::POST_DISPATCH_NONE;
+}
+
void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
if (submenu->IsShowing()) {
gfx::Point point = GetScreen()->GetCursorScreenPoint();

Powered by Google App Engine
This is Rietveld 408576698