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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/accessibility/ax_node_data.h" | 8 #include "ui/accessibility/ax_node_data.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 if (tooltip_text_.empty()) | 58 if (tooltip_text_.empty()) |
59 return false; | 59 return false; |
60 | 60 |
61 *tooltip = tooltip_text_; | 61 *tooltip = tooltip_text_; |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
65 void Button::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 65 void Button::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
66 node_data->role = ui::AX_ROLE_BUTTON; | 66 node_data->role = ui::AX_ROLE_BUTTON; |
67 node_data->SetName(accessible_name_); | 67 node_data->SetName(accessible_name_); |
| 68 if (!enabled()) |
| 69 node_data->AddStateFlag(ui::AX_STATE_DISABLED); |
68 } | 70 } |
69 | 71 |
70 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
71 // Button, protected: | 73 // Button, protected: |
72 | 74 |
73 Button::Button(ButtonListener* listener) | 75 Button::Button(ButtonListener* listener) |
74 : listener_(listener), | 76 : listener_(listener), |
75 tag_(-1) { | 77 tag_(-1) { |
76 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 78 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
77 } | 79 } |
78 | 80 |
79 void Button::NotifyClick(const ui::Event& event) { | 81 void Button::NotifyClick(const ui::Event& event) { |
80 // We can be called when there is no listener, in cases like double clicks on | 82 // We can be called when there is no listener, in cases like double clicks on |
81 // menu buttons etc. | 83 // menu buttons etc. |
82 if (listener_) | 84 if (listener_) |
83 listener_->ButtonPressed(this, event); | 85 listener_->ButtonPressed(this, event); |
84 } | 86 } |
85 | 87 |
86 void Button::OnClickCanceled(const ui::Event& event) {} | 88 void Button::OnClickCanceled(const ui::Event& event) {} |
87 | 89 |
88 } // namespace views | 90 } // namespace views |
OLD | NEW |