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

Side by Side Diff: ui/views/controls/textfield/native_textfield_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/textfield/native_textfield_views.h" 5 #include "ui/views/controls/textfield/native_textfield_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 NativeTextfieldViews::~NativeTextfieldViews() { 99 NativeTextfieldViews::~NativeTextfieldViews() {
100 } 100 }
101 101
102 //////////////////////////////////////////////////////////////////////////////// 102 ////////////////////////////////////////////////////////////////////////////////
103 // NativeTextfieldViews, View overrides: 103 // NativeTextfieldViews, View overrides:
104 104
105 bool NativeTextfieldViews::OnMousePressed(const MouseEvent& event) { 105 bool NativeTextfieldViews::OnMousePressed(const MouseEvent& event) {
106 OnBeforeUserAction(); 106 OnBeforeUserAction();
107 TrackMouseClicks(event); 107 TrackMouseClicks(event);
108 108 // TODO: Remove once NativeTextfield implementations are consolidated to
109 // Allow the textfield/omnibox to optionally handle the mouse pressed event. 109 // Textfield.
110 // This should be removed once native textfield implementations are
111 // consolidated to textfield.
112 if (!textfield_->OnMousePressed(event)) 110 if (!textfield_->OnMousePressed(event))
113 HandleMousePressEvent(event); 111 HandleMousePressEvent(event);
114
115 OnAfterUserAction(); 112 OnAfterUserAction();
116 return true; 113 return true;
117 } 114 }
118 115
119 bool NativeTextfieldViews::ExceededDragThresholdFromLastClickLocation( 116 bool NativeTextfieldViews::ExceededDragThresholdFromLastClickLocation(
120 const MouseEvent& event) { 117 const MouseEvent& event) {
121 gfx::Point location_delta = event.location().Subtract(last_click_location_); 118 gfx::Point location_delta = event.location().Subtract(last_click_location_);
122 return ExceededDragThreshold(location_delta.x(), location_delta.y()); 119 return ExceededDragThreshold(location_delta.x(), location_delta.y());
123 } 120 }
124 121
125 bool NativeTextfieldViews::OnMouseDragged(const MouseEvent& event) { 122 bool NativeTextfieldViews::OnMouseDragged(const MouseEvent& event) {
126 // Don't adjust the cursor on a potential drag and drop, or if the mouse 123 // Don't adjust the cursor on a potential drag and drop, or if the mouse
127 // movement from the last mouse click does not exceed the drag threshold. 124 // movement from the last mouse click does not exceed the drag threshold.
128 if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event)) 125 if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event))
129 return true; 126 return true;
130 127
131 OnBeforeUserAction(); 128 OnBeforeUserAction();
132 if (MoveCursorTo(event.location(), true)) 129 // TODO: Remove once NativeTextfield implementations are consolidated to
133 SchedulePaint(); 130 // Textfield.
131 if (!textfield_->OnMouseDragged(event)) {
132 if (MoveCursorTo(event.location(), true))
133 SchedulePaint();
134 }
134 OnAfterUserAction(); 135 OnAfterUserAction();
135 return true; 136 return true;
136 } 137 }
137 138
138 void NativeTextfieldViews::OnMouseReleased(const MouseEvent& event) { 139 void NativeTextfieldViews::OnMouseReleased(const MouseEvent& event) {
139 OnBeforeUserAction(); 140 OnBeforeUserAction();
141 // TODO: Remove once NativeTextfield implementations are consolidated to
142 // Textfield.
143 textfield_->OnMouseReleased(event);
140 // Cancel suspected drag initiations, the user was clicking in the selection. 144 // Cancel suspected drag initiations, the user was clicking in the selection.
141 if (initiating_drag_ && MoveCursorTo(event.location(), false)) 145 if (initiating_drag_ && MoveCursorTo(event.location(), false))
142 SchedulePaint(); 146 SchedulePaint();
143 initiating_drag_ = false; 147 initiating_drag_ = false;
144 OnAfterUserAction(); 148 OnAfterUserAction();
145 } 149 }
146 150
147 bool NativeTextfieldViews::OnKeyPressed(const KeyEvent& event) { 151 bool NativeTextfieldViews::OnKeyPressed(const KeyEvent& event) {
148 // OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on 152 // OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on
149 // NativeTextfieldViews as it will never gain focus. 153 // NativeTextfieldViews as it will never gain focus.
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1154
1151 #if defined(USE_AURA) 1155 #if defined(USE_AURA)
1152 // static 1156 // static
1153 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1157 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1154 Textfield* field) { 1158 Textfield* field) {
1155 return new NativeTextfieldViews(field); 1159 return new NativeTextfieldViews(field);
1156 } 1160 }
1157 #endif 1161 #endif
1158 1162
1159 } // namespace views 1163 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698