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

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

Issue 13896002: Tweak Views Omnibox/Textfield; re-enable OmniboxViewTest.SelectAllOnClick. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix click location; enable for TOOLKIT_VIEWS; fix Views Textfields middle/right-click. 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/omnibox/omnibox_view_browsertest.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/native_textfield_views.cc
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index f181fbff4b08305a9d83b3403837be77e9de6792..41560a86ac641d8f8a4b0dd9a1dd6967811c1b08 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -121,8 +121,10 @@ bool NativeTextfieldViews::ExceededDragThresholdFromLastClickLocation(
bool NativeTextfieldViews::OnMouseDragged(const ui::MouseEvent& event) {
// Don't adjust the cursor on a potential drag and drop, or if the mouse
// movement from the last mouse click does not exceed the drag threshold.
- if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event))
+ if (initiating_drag_ || !ExceededDragThresholdFromLastClickLocation(event) ||
+ !event.IsOnlyLeftMouseButton()) {
return true;
+ }
OnBeforeUserAction();
// TODO: Remove once NativeTextfield implementations are consolidated to
@@ -1349,33 +1351,35 @@ void NativeTextfieldViews::TrackMouseClicks(const ui::MouseEvent& event) {
}
void NativeTextfieldViews::HandleMousePressEvent(const ui::MouseEvent& event) {
- if (event.IsOnlyLeftMouseButton()) {
+ if (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton())
textfield_->RequestFocus();
- initiating_drag_ = false;
- bool can_drag = true;
+ if (!event.IsOnlyLeftMouseButton())
+ return;
- switch (aggregated_clicks_) {
- case 0:
- if (can_drag && GetRenderText()->IsPointInSelection(event.location()))
- initiating_drag_ = true;
- else
- MoveCursorTo(event.location(), event.IsShiftDown());
- break;
- case 1:
- MoveCursorTo(event.location(), false);
- model_->SelectWord();
- OnCaretBoundsChanged();
- break;
- case 2:
- model_->SelectAll(false);
- OnCaretBoundsChanged();
- break;
- default:
- NOTREACHED();
- }
- SchedulePaint();
+ initiating_drag_ = false;
+ bool can_drag = true;
+
+ switch (aggregated_clicks_) {
+ case 0:
+ if (can_drag && GetRenderText()->IsPointInSelection(event.location()))
+ initiating_drag_ = true;
+ else
+ MoveCursorTo(event.location(), event.IsShiftDown());
+ break;
+ case 1:
+ MoveCursorTo(event.location(), false);
+ model_->SelectWord();
+ OnCaretBoundsChanged();
+ break;
+ case 2:
+ model_->SelectAll(false);
+ OnCaretBoundsChanged();
+ break;
+ default:
+ NOTREACHED();
}
+ SchedulePaint();
}
bool NativeTextfieldViews::ImeEditingAllowed() const {
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_view_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698