| Index: ui/views/focus/focus_manager.cc
|
| diff --git a/ui/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc
|
| index 1467f252275335f1088af327941b2284b997f76b..9eda5110fc8ab620057149281994580a1f69ae23 100644
|
| --- a/ui/views/focus/focus_manager.cc
|
| +++ b/ui/views/focus/focus_manager.cc
|
| @@ -54,22 +54,23 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) {
|
| if (event.type() == ui::ET_KEY_PRESSED) {
|
| // VKEY_MENU is triggered by key release event.
|
| // FocusManager::OnKeyEvent() returns false when the key has been consumed.
|
| - if (key_code == ui::VKEY_MENU) {
|
| + if ((key_code == ui::VKEY_MENU) &&
|
| + (event.flags() & ~ui::EF_ALT_DOWN) == 0) {
|
| should_handle_menu_key_release_ = true;
|
| return false;
|
| }
|
| - // Pass through to the reset of OnKeyEvent.
|
| + // Pass through to the rest of OnKeyEvent.
|
| } else if (key_code == ui::VKEY_MENU && should_handle_menu_key_release_ &&
|
| (event.flags() & ~ui::EF_ALT_DOWN) == 0) {
|
| // Trigger VKEY_MENU when only this key is pressed and released, and both
|
| // press and release events are not handled by others.
|
| ui::Accelerator accelerator(ui::VKEY_MENU, false, false, false);
|
| return ProcessAccelerator(accelerator);
|
| - } else {
|
| + } else if (event.type() != ui::ET_KEY_RELEASED) {
|
| return false;
|
| }
|
| #else
|
| - if (event.type() != ui::ET_KEY_PRESSED)
|
| + if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED)
|
| return false;
|
| #endif
|
|
|
| @@ -77,53 +78,57 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) {
|
| event.IsShiftDown(),
|
| event.IsControlDown(),
|
| event.IsAltDown());
|
| + accelerator.set_type(event.type());
|
|
|
| + if (event.type() == ui::ET_KEY_PRESSED) {
|
| #if defined(OS_WIN)
|
| - // If the focused view wants to process the key event as is, let it be.
|
| - // This is not used for linux/aura.
|
| - if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) &&
|
| - !accelerator_manager_->HasPriorityHandler(accelerator))
|
| - return true;
|
| + // If the focused view wants to process the key event as is, let it be.
|
| + // This is not used for linux/aura.
|
| + if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) &&
|
| + !accelerator_manager_->HasPriorityHandler(accelerator))
|
| + return true;
|
| #endif
|
|
|
| - // Intercept Tab related messages for focus traversal.
|
| - // Note that we don't do focus traversal if the root window is not part of the
|
| - // active window hierarchy as this would mean we have no focused view and
|
| - // would focus the first focusable view.
|
| + // Intercept Tab related messages for focus traversal.
|
| + // Note that we don't do focus traversal if the root window is not part of
|
| + // the active window hierarchy as this would mean we have no focused view
|
| + // and would focus the first focusable view.
|
| #if defined(OS_WIN) && !defined(USE_AURA)
|
| - HWND top_window = widget_->GetNativeView();
|
| - HWND active_window = ::GetActiveWindow();
|
| - if ((active_window == top_window || ::IsChild(active_window, top_window)) &&
|
| - IsTabTraversalKeyEvent(event)) {
|
| - AdvanceFocus(event.IsShiftDown());
|
| - return false;
|
| - }
|
| + HWND top_window = widget_->GetNativeView();
|
| + HWND active_window = ::GetActiveWindow();
|
| + if ((active_window == top_window || ::IsChild(active_window, top_window)) &&
|
| + IsTabTraversalKeyEvent(event)) {
|
| + AdvanceFocus(event.IsShiftDown());
|
| + return false;
|
| + }
|
| #else
|
| - if (IsTabTraversalKeyEvent(event)) {
|
| - AdvanceFocus(event.IsShiftDown());
|
| - return false;
|
| - }
|
| + if (IsTabTraversalKeyEvent(event)) {
|
| + AdvanceFocus(event.IsShiftDown());
|
| + return false;
|
| + }
|
| #endif
|
|
|
| - // Intercept arrow key messages to switch between grouped views.
|
| - if (focused_view_ && focused_view_->GetGroup() != -1 &&
|
| - (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN ||
|
| - key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) {
|
| - bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN);
|
| - View::Views views;
|
| - focused_view_->parent()->GetViewsInGroup(focused_view_->GetGroup(), &views);
|
| - View::Views::const_iterator i(
|
| - std::find(views.begin(), views.end(), focused_view_));
|
| - DCHECK(i != views.end());
|
| - int index = static_cast<int>(i - views.begin());
|
| - index += next ? 1 : -1;
|
| - if (index < 0) {
|
| - index = static_cast<int>(views.size()) - 1;
|
| - } else if (index >= static_cast<int>(views.size())) {
|
| - index = 0;
|
| + // Intercept arrow key messages to switch between grouped views.
|
| + if (focused_view_ && focused_view_->GetGroup() != -1 &&
|
| + (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN ||
|
| + key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) {
|
| + bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN);
|
| + View::Views views;
|
| + focused_view_->parent()->GetViewsInGroup(focused_view_->GetGroup(),
|
| + &views);
|
| + View::Views::const_iterator i(
|
| + std::find(views.begin(), views.end(), focused_view_));
|
| + DCHECK(i != views.end());
|
| + int index = static_cast<int>(i - views.begin());
|
| + index += next ? 1 : -1;
|
| + if (index < 0) {
|
| + index = static_cast<int>(views.size()) - 1;
|
| + } else if (index >= static_cast<int>(views.size())) {
|
| + index = 0;
|
| + }
|
| + SetFocusedViewWithReason(views[index], kReasonFocusTraversal);
|
| + return false;
|
| }
|
| - SetFocusedViewWithReason(views[index], kReasonFocusTraversal);
|
| - return false;
|
| }
|
|
|
| // Process keyboard accelerators.
|
|
|