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/strings/utf_string_conversions.h" | 7 #include "base/strings/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/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // BaseButton::OnMouseExited will get the event and will set the button's state | 195 // BaseButton::OnMouseExited will get the event and will set the button's state |
196 // to STATE_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will | 196 // to STATE_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will |
197 // cause the button to appear depressed while the menu is displayed. | 197 // cause the button to appear depressed while the menu is displayed. |
198 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { | 198 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { |
199 if ((state_ != STATE_DISABLED) && (!menu_visible_) && (!InDrag())) { | 199 if ((state_ != STATE_DISABLED) && (!menu_visible_) && (!InDrag())) { |
200 SetState(STATE_NORMAL); | 200 SetState(STATE_NORMAL); |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 void MenuButton::OnGestureEvent(ui::GestureEvent* event) { | 204 void MenuButton::OnGestureEvent(ui::GestureEvent* event) { |
205 if (state() != STATE_DISABLED && event->type() == ui::ET_GESTURE_TAP) { | 205 if (state() != STATE_DISABLED && event->type() == ui::ET_GESTURE_TAP && |
206 if (Activate()) | 206 !Activate()) { |
207 event->StopPropagation(); | 207 // When |Activate()| returns |false|, it means that a menu is shown and |
| 208 // has handled the gesture event. So, there is no need to further process |
| 209 // the gesture event here. |
208 return; | 210 return; |
209 } | 211 } |
210 TextButton::OnGestureEvent(event); | 212 TextButton::OnGestureEvent(event); |
211 } | 213 } |
212 | 214 |
213 bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) { | 215 bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) { |
214 switch (event.key_code()) { | 216 switch (event.key_code()) { |
215 case ui::VKEY_SPACE: | 217 case ui::VKEY_SPACE: |
216 // Alt-space on windows should show the window menu. | 218 // Alt-space on windows should show the window menu. |
217 if (event.IsAltDown()) | 219 if (event.IsAltDown()) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 if (!GetWidget()) { | 269 if (!GetWidget()) { |
268 NOTREACHED(); | 270 NOTREACHED(); |
269 return 0; | 271 return 0; |
270 } | 272 } |
271 | 273 |
272 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); | 274 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); |
273 return monitor_bounds.right() - 1; | 275 return monitor_bounds.right() - 1; |
274 } | 276 } |
275 | 277 |
276 } // namespace views | 278 } // namespace views |
OLD | NEW |