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/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
6 | 6 |
7 #include "ui/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 UpdateInkDropHoverState(); | 135 UpdateInkDropHoverState(); |
136 } | 136 } |
137 | 137 |
138 const char* CustomButton::GetClassName() const { | 138 const char* CustomButton::GetClassName() const { |
139 return kViewClassName; | 139 return kViewClassName; |
140 } | 140 } |
141 | 141 |
142 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { | 142 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { |
143 if (state_ == STATE_DISABLED) | 143 if (state_ == STATE_DISABLED) |
144 return true; | 144 return true; |
145 if (ShouldEnterPushedState(event) && HitTestPoint(event.location())) { | 145 if (state_ != STATE_PRESSED && ShouldEnterPushedState(event) && |
| 146 HitTestPoint(event.location())) { |
146 SetState(STATE_PRESSED); | 147 SetState(STATE_PRESSED); |
147 if (ink_drop_delegate_) | 148 if (ink_drop_delegate_) |
148 ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING); | 149 ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING); |
149 } | 150 } |
150 if (request_focus_on_press_) | 151 if (request_focus_on_press_) |
151 RequestFocus(); | 152 RequestFocus(); |
152 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { | 153 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { |
153 NotifyClick(event); | 154 NotifyClick(event); |
154 // NOTE: We may be deleted at this point (by the listener's notification | 155 // NOTE: We may be deleted at this point (by the listener's notification |
155 // handler). | 156 // handler). |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); | 457 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); |
457 } | 458 } |
458 | 459 |
459 bool CustomButton::FocusInChildWidget() const { | 460 bool CustomButton::FocusInChildWidget() const { |
460 return GetWidget() && | 461 return GetWidget() && |
461 GetWidget()->GetRootView()->Contains( | 462 GetWidget()->GetRootView()->Contains( |
462 GetFocusManager()->GetFocusedView()); | 463 GetFocusManager()->GetFocusedView()); |
463 } | 464 } |
464 | 465 |
465 } // namespace views | 466 } // namespace views |
OLD | NEW |