Chromium Code Reviews| Index: ui/views/controls/textfield/textfield.cc |
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
| index 14736697771bda755ab2e7e08f2ad70cc1fee919..32771b459334186d9f647080cce01ebc6b4d3d27 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -967,6 +967,12 @@ void Textfield::OnEnabledChanged() { |
| } |
| void Textfield::OnPaint(gfx::Canvas* canvas) { |
| + // If the textfield was the last focused view before switching windows, draw |
| + // the text selection greyed out. |
| + if (!HasFocus() && |
| + GetWidget()->GetFocusManager()->GetStoredFocusView() == this) |
| + GetRenderText()->set_draw_unfocused_selection(true); |
| + |
| OnPaintBackground(canvas); |
| PaintTextAndCursor(canvas); |
| OnPaintBorder(canvas); |
| @@ -974,6 +980,7 @@ void Textfield::OnPaint(gfx::Canvas* canvas) { |
| void Textfield::OnFocus() { |
| GetRenderText()->set_focused(true); |
| + GetRenderText()->set_draw_unfocused_selection(false); |
| cursor_visible_ = true; |
| SchedulePaint(); |
| if (GetInputMethod()) |
| @@ -1000,6 +1007,10 @@ void Textfield::OnBlur() { |
| cursor_visible_ = false; |
| RepaintCursor(); |
| } |
| + // Another focused View in the same Widget means the user is interacting with |
| + // something else and the text selection is no longer needed. |
| + if (GetWidget()->GetFocusManager()->GetFocusedView()) |
| + ClearSelection(); |
|
tapted
2016/09/20 06:57:55
There are some comments in http://crbug.com/331038
Patti Lor
2016/10/12 05:53:00
I don't think we need to change FocusChangeReason
|
| DestroyTouchSelection(); |