| OLD | NEW |
| 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/button/menu_button.h" | 5 #include "ui/views/controls/button/menu_button.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "grit/ui_strings.h" | 9 #include "grit/ui_strings.h" |
| 10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // we display the menu. If we don't override this method then | 212 // we display the menu. If we don't override this method then |
| 213 // BaseButton::OnMouseExited will get the event and will set the button's state | 213 // BaseButton::OnMouseExited will get the event and will set the button's state |
| 214 // to STATE_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will | 214 // to STATE_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will |
| 215 // cause the button to appear depressed while the menu is displayed. | 215 // cause the button to appear depressed while the menu is displayed. |
| 216 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { | 216 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { |
| 217 if ((state_ != STATE_DISABLED) && (!menu_visible_) && (!InDrag())) { | 217 if ((state_ != STATE_DISABLED) && (!menu_visible_) && (!InDrag())) { |
| 218 SetState(STATE_NORMAL); | 218 SetState(STATE_NORMAL); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 ui::EventResult MenuButton::OnGestureEvent(ui::GestureEvent* event) { | 222 void MenuButton::OnGestureEvent(ui::GestureEvent* event) { |
| 223 if (state() != STATE_DISABLED && event->type() == ui::ET_GESTURE_TAP) { | 223 if (state() != STATE_DISABLED && event->type() == ui::ET_GESTURE_TAP) { |
| 224 if (Activate()) | 224 if (Activate()) |
| 225 return ui::ER_CONSUMED; | 225 event->StopPropagation(); |
| 226 return ui::ER_UNHANDLED; | 226 return; |
| 227 } | 227 } |
| 228 return TextButton::OnGestureEvent(event); | 228 TextButton::OnGestureEvent(event); |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) { | 231 bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) { |
| 232 switch (event.key_code()) { | 232 switch (event.key_code()) { |
| 233 case ui::VKEY_SPACE: | 233 case ui::VKEY_SPACE: |
| 234 // Alt-space on windows should show the window menu. | 234 // Alt-space on windows should show the window menu. |
| 235 if (event.IsAltDown()) | 235 if (event.IsAltDown()) |
| 236 break; | 236 break; |
| 237 case ui::VKEY_RETURN: | 237 case ui::VKEY_RETURN: |
| 238 case ui::VKEY_UP: | 238 case ui::VKEY_UP: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 264 if (!GetWidget()) { | 264 if (!GetWidget()) { |
| 265 NOTREACHED(); | 265 NOTREACHED(); |
| 266 return 0; | 266 return 0; |
| 267 } | 267 } |
| 268 | 268 |
| 269 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); | 269 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); |
| 270 return monitor_bounds.right() - 1; | 270 return monitor_bounds.right() - 1; |
| 271 } | 271 } |
| 272 | 272 |
| 273 } // namespace views | 273 } // namespace views |
| OLD | NEW |