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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | 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/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 797
798 void MenuController::OnDragComplete(bool should_close) { 798 void MenuController::OnDragComplete(bool should_close) {
799 DCHECK(drag_in_progress_); 799 DCHECK(drag_in_progress_);
800 drag_in_progress_ = false; 800 drag_in_progress_ = false;
801 if (showing_ && should_close && GetActiveInstance() == this) { 801 if (showing_ && should_close && GetActiveInstance() == this) {
802 CloseAllNestedMenus(); 802 CloseAllNestedMenus();
803 Cancel(EXIT_ALL); 803 Cancel(EXIT_ALL);
804 } 804 }
805 } 805 }
806 806
807 ui::PostDispatchAction MenuController::OnWillDispatchKeyEvent(
808 base::char16 character,
809 ui::KeyboardCode key_code) {
810 if (exit_type() == MenuController::EXIT_ALL ||
811 exit_type() == MenuController::EXIT_DESTROYED) {
812 TerminateNestedMessageLoop();
813 return ui::POST_DISPATCH_PERFORM_DEFAULT;
814 }
815
816 bool should_quit = character ? SelectByChar(character) : !OnKeyDown(key_code);
817 if (should_quit || exit_type() != MenuController::EXIT_NONE)
818 TerminateNestedMessageLoop();
819
820 return ui::POST_DISPATCH_NONE;
821 }
tapted 2015/02/04 11:55:48 This function started life being refactored out of
822
807 void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) { 823 void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
808 if (submenu->IsShowing()) { 824 if (submenu->IsShowing()) {
809 gfx::Point point = GetScreen()->GetCursorScreenPoint(); 825 gfx::Point point = GetScreen()->GetCursorScreenPoint();
810 const SubmenuView* root_submenu = 826 const SubmenuView* root_submenu =
811 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu(); 827 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu();
812 View::ConvertPointFromScreen( 828 View::ConvertPointFromScreen(
813 root_submenu->GetWidget()->GetRootView(), &point); 829 root_submenu->GetWidget()->GetRootView(), &point);
814 HandleMouseLocation(submenu, point); 830 HandleMouseLocation(submenu, point);
815 } 831 }
816 } 832 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 OpenSubmenuChangeSelectionIfCan(); 1037 OpenSubmenuChangeSelectionIfCan();
1022 break; 1038 break;
1023 1039
1024 case ui::VKEY_LEFT: 1040 case ui::VKEY_LEFT:
1025 if (base::i18n::IsRTL()) 1041 if (base::i18n::IsRTL())
1026 OpenSubmenuChangeSelectionIfCan(); 1042 OpenSubmenuChangeSelectionIfCan();
1027 else 1043 else
1028 CloseSubmenu(); 1044 CloseSubmenu();
1029 break; 1045 break;
1030 1046
1047 // On Mac, treat space the same as return.
1048 #if !defined(OS_MACOSX)
1031 case ui::VKEY_SPACE: 1049 case ui::VKEY_SPACE:
1032 if (SendAcceleratorToHotTrackedView() == ACCELERATOR_PROCESSED_EXIT) 1050 if (SendAcceleratorToHotTrackedView() == ACCELERATOR_PROCESSED_EXIT)
1033 return false; 1051 return false;
1034 break; 1052 break;
1053 #endif
1035 1054
1036 case ui::VKEY_F4: 1055 case ui::VKEY_F4:
1037 if (!is_combobox_) 1056 if (!is_combobox_)
1038 break; 1057 break;
1039 // Fallthrough to accept or dismiss combobox menus on F4, like windows. 1058 // Fallthrough to accept or dismiss combobox menus on F4, like windows.
1040 case ui::VKEY_RETURN: 1059 case ui::VKEY_RETURN:
1060 #if defined(OS_MACOSX)
1061 case ui::VKEY_SPACE:
1062 #endif
1041 if (pending_state_.item) { 1063 if (pending_state_.item) {
1042 if (pending_state_.item->HasSubmenu()) { 1064 if (pending_state_.item->HasSubmenu()) {
1043 if (key_code == ui::VKEY_F4 && 1065 if (key_code == ui::VKEY_F4 &&
1044 pending_state_.item->GetSubmenu()->IsShowing()) 1066 pending_state_.item->GetSubmenu()->IsShowing())
1045 return false; 1067 return false;
1046 else 1068 else
1047 OpenSubmenuChangeSelectionIfCan(); 1069 OpenSubmenuChangeSelectionIfCan();
1048 } else { 1070 } else {
1049 SendAcceleratorResultType result = SendAcceleratorToHotTrackedView(); 1071 SendAcceleratorResultType result = SendAcceleratorToHotTrackedView();
1050 if (result == ACCELERATOR_NOT_PROCESSED && 1072 if (result == ACCELERATOR_NOT_PROCESSED &&
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 } 2328 }
2307 } 2329 }
2308 2330
2309 gfx::Screen* MenuController::GetScreen() { 2331 gfx::Screen* MenuController::GetScreen() {
2310 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2332 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2311 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2333 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2312 : gfx::Screen::GetNativeScreen(); 2334 : gfx::Screen::GetNativeScreen();
2313 } 2335 }
2314 2336
2315 } // namespace views 2337 } // namespace views
OLDNEW
« 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