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

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

Issue 1073523005: Fix Views Textfield drag selection behavior past edges. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support dragging to the right edge too. Created 5 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 | « no previous file | 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 8fce3257fb0473455c8e8eba9476793e32adb4c3..6eea993064381734d19a2b21ebaa8b595b931907 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -647,11 +647,14 @@ bool Textfield::OnMouseDragged(const ui::MouseEvent& event) {
}
// A timer is used to continuously scroll while selecting beyond side edges.
- if ((event.location().x() > 0 && event.location().x() < size().width()) ||
- GetDragSelectionDelay() == 0) {
+ const int x = event.location().x();
+ if ((x >= 0 && x <= width()) || GetDragSelectionDelay() == 0) {
drag_selection_timer_.Stop();
SelectThroughLastDragLocation();
} else if (!drag_selection_timer_.IsRunning()) {
+ // Select through the edge of the visible text, then start the scroll timer.
+ last_drag_location_.set_x(std::min(std::max(0, x), width()));
+ SelectThroughLastDragLocation();
drag_selection_timer_.Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(GetDragSelectionDelay()),
this, &Textfield::SelectThroughLastDragLocation);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698