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/keycodes/keyboard_codes.h" | 9 #include "ui/events/keycodes/keyboard_codes.h" |
10 #include "ui/gfx/animation/throb_animation.h" | 10 #include "ui/gfx/animation/throb_animation.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 return; | 266 return; |
267 | 267 |
268 // We're about to show the context menu. Showing the context menu likely means | 268 // We're about to show the context menu. Showing the context menu likely means |
269 // we won't get a mouse exited and reset state. Reset it now to be sure. | 269 // we won't get a mouse exited and reset state. Reset it now to be sure. |
270 if (state_ != STATE_DISABLED) | 270 if (state_ != STATE_DISABLED) |
271 SetState(STATE_NORMAL); | 271 SetState(STATE_NORMAL); |
272 View::ShowContextMenu(p, source_type); | 272 View::ShowContextMenu(p, source_type); |
273 } | 273 } |
274 | 274 |
275 void CustomButton::OnDragDone() { | 275 void CustomButton::OnDragDone() { |
276 SetState(STATE_NORMAL); | 276 // Only reset the state to normal if the button isn't currently disabled |
| 277 // (since disabled buttons may still be able to be dragged). |
| 278 if (state_ != STATE_DISABLED) |
| 279 SetState(STATE_NORMAL); |
277 } | 280 } |
278 | 281 |
279 void CustomButton::GetAccessibleState(ui::AXViewState* state) { | 282 void CustomButton::GetAccessibleState(ui::AXViewState* state) { |
280 Button::GetAccessibleState(state); | 283 Button::GetAccessibleState(state); |
281 switch (state_) { | 284 switch (state_) { |
282 case STATE_HOVERED: | 285 case STATE_HOVERED: |
283 state->AddStateFlag(ui::AX_STATE_HOVERED); | 286 state->AddStateFlag(ui::AX_STATE_HOVERED); |
284 break; | 287 break; |
285 case STATE_PRESSED: | 288 case STATE_PRESSED: |
286 state->AddStateFlag(ui::AX_STATE_PRESSED); | 289 state->AddStateFlag(ui::AX_STATE_PRESSED); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 if (!details.is_add && state_ != STATE_DISABLED) | 347 if (!details.is_add && state_ != STATE_DISABLED) |
345 SetState(STATE_NORMAL); | 348 SetState(STATE_NORMAL); |
346 } | 349 } |
347 | 350 |
348 void CustomButton::OnBlur() { | 351 void CustomButton::OnBlur() { |
349 if (IsHotTracked()) | 352 if (IsHotTracked()) |
350 SetState(STATE_NORMAL); | 353 SetState(STATE_NORMAL); |
351 } | 354 } |
352 | 355 |
353 } // namespace views | 356 } // namespace views |
OLD | NEW |