Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2345183002: Views: Draw Textfield selected text in gray when top-level Widget loses focus.
Patch Set: Fix up diff & add colors to Windows/Mac. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/native_theme/native_theme_win.cc ('K') | « ui/native_theme/native_theme_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« ui/native_theme/native_theme_win.cc ('K') | « ui/native_theme/native_theme_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698