| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/button.h" | 5 #include "ui/views/controls/button/button.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 43 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| 44 state->name = accessible_name_; | 44 state->name = accessible_name_; |
| 45 state->keyboard_shortcut = accessible_shortcut_; | 45 state->keyboard_shortcut = accessible_shortcut_; |
| 46 } | 46 } |
| 47 | 47 |
| 48 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
| 49 // Button, protected: | 49 // Button, protected: |
| 50 | 50 |
| 51 Button::Button(ButtonListener* listener) | 51 Button::Button(ButtonListener* listener) |
| 52 : listener_(listener), | 52 : listener_(listener), |
| 53 tag_(-1), | 53 tag_(-1) { |
| 54 mouse_event_flags_(0) { | |
| 55 set_accessibility_focusable(true); | 54 set_accessibility_focusable(true); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void Button::NotifyClick(const ui::Event& event) { | 57 void Button::NotifyClick(const ui::Event& event) { |
| 59 mouse_event_flags_ = event.IsMouseEvent() ? event.flags() : 0; | |
| 60 // We can be called when there is no listener, in cases like double clicks on | 58 // We can be called when there is no listener, in cases like double clicks on |
| 61 // menu buttons etc. | 59 // menu buttons etc. |
| 62 if (listener_) | 60 if (listener_) |
| 63 listener_->ButtonPressed(this, event); | 61 listener_->ButtonPressed(this, event); |
| 64 // NOTE: don't attempt to reset mouse_event_flags_ as the listener may have | |
| 65 // deleted us. | |
| 66 } | 62 } |
| 67 | 63 |
| 68 } // namespace views | 64 } // namespace views |
| OLD | NEW |