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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 10386173: ash: Select omnibox text on mouse up instead of down. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge and add test todo Created 8 years, 7 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
Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 7aa4893269ee952fa42c2712cf1534eb5ba945c6..fec59621baee963a1339932eb842b85d2468406d 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -87,7 +87,22 @@ class AutocompleteTextfield : public views::Textfield {
}
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
- return omnibox_view_->HandleMousePressEvent(event);
+ // Pass through the views::Textfield's return value; we don't need to
+ // override its behavior.
+ bool result = views::Textfield::OnMousePressed(event);
+ omnibox_view_->HandleMousePressEvent(event);
+ return result;
+ }
+
+ virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE {
+ bool result = views::Textfield::OnMouseDragged(event);
+ omnibox_view_->HandleMouseDragEvent(event);
+ return result;
+ }
+
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE {
+ views::Textfield::OnMouseReleased(event);
+ omnibox_view_->HandleMouseReleaseEvent(event);
}
private:
@@ -180,7 +195,8 @@ OmniboxViewViews::OmniboxViewViews(AutocompleteEditController* controller,
ime_composing_before_change_(false),
delete_at_end_pressed_(false),
location_bar_view_(location_bar),
- ime_candidate_window_open_(false) {
+ ime_candidate_window_open_(false),
+ select_all_on_mouse_release_(false) {
}
OmniboxViewViews::~OmniboxViewViews() {
@@ -305,14 +321,22 @@ bool OmniboxViewViews::HandleKeyReleaseEvent(const views::KeyEvent& event) {
return false;
}
-bool OmniboxViewViews::HandleMousePressEvent(const views::MouseEvent& event) {
- if (!textfield_->HasFocus() && !textfield_->HasSelection()) {
+void OmniboxViewViews::HandleMousePressEvent(const views::MouseEvent& event) {
+ select_all_on_mouse_release_ =
+ (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
+ !textfield_->HasFocus();
+}
+
+void OmniboxViewViews::HandleMouseDragEvent(const views::MouseEvent& event) {
+ select_all_on_mouse_release_ = false;
+}
+
+void OmniboxViewViews::HandleMouseReleaseEvent(const views::MouseEvent& event) {
+ if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
+ select_all_on_mouse_release_) {
textfield_->SelectAll();
- textfield_->RequestFocus();
- return true;
}
-
- return false;
+ select_all_on_mouse_release_ = false;
}
void OmniboxViewViews::HandleFocusIn() {
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | ui/views/controls/textfield/native_textfield_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698