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

Unified Diff: chrome/browser/ui/views/find_bar_view.cc

Issue 13852009: Replace find bar RequestFocus override with OnFocus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a comment about select_all_on_focus_. Created 7 years, 8 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
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.h ('k') | ui/views/view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/find_bar_view.cc
diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc
index 28bb7ddb812558444627fc738b38f66dd92be2c8..930a5347e4f02a236b99f44351fd9bfd3e2ce8ff 100644
--- a/chrome/browser/ui/views/find_bar_view.cc
+++ b/chrome/browser/ui/views/find_bar_view.cc
@@ -498,15 +498,29 @@ bool FindBarView::FocusForwarderView::OnMousePressed(
return true;
}
-FindBarView::SearchTextfieldView::SearchTextfieldView() {}
+FindBarView::SearchTextfieldView::SearchTextfieldView()
+ : select_all_on_focus_(true) {}
FindBarView::SearchTextfieldView::~SearchTextfieldView() {}
-void FindBarView::SearchTextfieldView::RequestFocus() {
- if (HasFocus())
- return;
- views::View::RequestFocus();
- SelectAll(true);
+bool FindBarView::SearchTextfieldView::OnMousePressed(
+ const ui::MouseEvent& event) {
+ // Avoid temporarily selecting all the text on focus from a mouse press; this
+ // prevents flickering before setting a cursor or dragging to select text.
+ select_all_on_focus_ = false;
+ return views::Textfield::OnMousePressed(event);
+}
+
+void FindBarView::SearchTextfieldView::OnMouseReleased(
+ const ui::MouseEvent& event) {
+ views::Textfield::OnMouseReleased(event);
+ select_all_on_focus_ = true;
+}
+
+void FindBarView::SearchTextfieldView::OnFocus() {
+ views::Textfield::OnFocus();
+ if (select_all_on_focus_)
+ SelectAll(true);
}
FindBarHost* FindBarView::find_bar_host() const {
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698