Chromium Code Reviews| Index: ui/views/controls/label.cc |
| diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc |
| index 9b04c091ff1ab436580068f0d8a18cb0e9526562..70635fe94615d3f2f4b38750ec670f6d2822789c 100644 |
| --- a/ui/views/controls/label.cc |
| +++ b/ui/views/controls/label.cc |
| @@ -509,6 +509,8 @@ bool Label::OnMousePressed(const ui::MouseEvent& event) { |
| if (!GetRenderTextForSelectionController()) |
| return false; |
| + const bool has_focus = HasFocus(); |
|
tapted
2017/01/25 09:11:16
optional: maybe had_focus?
karandeepb
2017/01/25 10:43:55
Done.
|
| + |
| // RequestFocus() won't work when the label has FocusBehavior::NEVER. Hence |
| // explicitly set the focused view. |
| // TODO(karandeepb): If a widget with a label having FocusBehavior::NEVER as |
| @@ -517,16 +519,18 @@ bool Label::OnMousePressed(const ui::MouseEvent& event) { |
| // when the widget gets focus again. Fix this. |
| // Tracked in https://crbug.com/630365. |
| if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) && |
| - GetFocusManager()) { |
| + GetFocusManager() && !has_focus) { |
| GetFocusManager()->SetFocusedView(this); |
| } |
| #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| - if (event.IsOnlyMiddleMouseButton() && GetFocusManager()) |
| + if (event.IsOnlyMiddleMouseButton() && GetFocusManager() && !has_focus) |
| GetFocusManager()->SetFocusedView(this); |
| #endif |
| - return selection_controller_->OnMousePressed(event, false); |
| + return selection_controller_->OnMousePressed( |
| + event, false, has_focus ? SelectionController::FOCUSED |
| + : SelectionController::UNFOCUSED); |
| } |
| bool Label::OnMouseDragged(const ui::MouseEvent& event) { |