OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/button/menu_button.h" | 5 #include "views/controls/button/menu_button.h" |
6 | 6 |
7 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "gfx/canvas.h" | 10 #include "gfx/canvas.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 e.GetKeyCode() == base::VKEY_UP || | 219 e.GetKeyCode() == base::VKEY_UP || |
220 e.GetKeyCode() == base::VKEY_DOWN) { | 220 e.GetKeyCode() == base::VKEY_DOWN) { |
221 bool result = Activate(); | 221 bool result = Activate(); |
222 if (GetFocusManager()->GetFocusedView() == NULL) | 222 if (GetFocusManager()->GetFocusedView() == NULL) |
223 RequestFocus(); | 223 RequestFocus(); |
224 return result; | 224 return result; |
225 } | 225 } |
226 return false; | 226 return false; |
227 } | 227 } |
228 | 228 |
| 229 bool MenuButton::OnKeyReleased(const KeyEvent& e) { |
| 230 // Override CustomButton's implementation, which presses the button when |
| 231 // you press space and clicks it when you release space. For a MenuButton |
| 232 // we always activate the menu on key press. |
| 233 return false; |
| 234 } |
| 235 |
229 // The reason we override View::OnMouseExited is because we get this event when | 236 // The reason we override View::OnMouseExited is because we get this event when |
230 // we display the menu. If we don't override this method then | 237 // we display the menu. If we don't override this method then |
231 // BaseButton::OnMouseExited will get the event and will set the button's state | 238 // BaseButton::OnMouseExited will get the event and will set the button's state |
232 // to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will | 239 // to BS_NORMAL instead of keeping the state BM_PUSHED. This, in turn, will |
233 // cause the button to appear depressed while the menu is displayed. | 240 // cause the button to appear depressed while the menu is displayed. |
234 void MenuButton::OnMouseExited(const MouseEvent& event) { | 241 void MenuButton::OnMouseExited(const MouseEvent& event) { |
235 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) { | 242 if ((state_ != BS_DISABLED) && (!menu_visible_) && (!InDrag())) { |
236 SetState(BS_NORMAL); | 243 SetState(BS_NORMAL); |
237 } | 244 } |
238 } | 245 } |
(...skipping 23 matching lines...) Expand all Loading... |
262 | 269 |
263 *state = AccessibilityTypes::STATE_HASPOPUP; | 270 *state = AccessibilityTypes::STATE_HASPOPUP; |
264 return true; | 271 return true; |
265 } | 272 } |
266 | 273 |
267 std::string MenuButton::GetClassName() const { | 274 std::string MenuButton::GetClassName() const { |
268 return kViewClassName; | 275 return kViewClassName; |
269 } | 276 } |
270 | 277 |
271 } // namespace views | 278 } // namespace views |
OLD | NEW |