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

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

Issue 1865063004: views: support vertical-drag-to-end on textfields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test on win/linux Created 4 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 | ui/views/controls/textfield/textfield_unittest.cc » ('j') | 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 2d16153419fdd89eb07b692851f25b9d4e3d0cb2..26e1678b0a70fc930ee31ed87040c75236074450 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -40,6 +40,7 @@
#include "ui/views/metrics.h"
#include "ui/views/native_cursor.h"
#include "ui/views/painter.h"
+#include "ui/views/style/platform_style.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
@@ -1746,7 +1747,18 @@ void Textfield::MoveCursorTo(const gfx::Point& point, bool select) {
void Textfield::SelectThroughLastDragLocation() {
OnBeforeUserAction();
- model_->MoveCursorTo(last_drag_location_, true);
+
+ const bool drags_to_end = PlatformStyle::kTextfieldDragVerticallyDragsToEnd;
+ if (drags_to_end && last_drag_location_.y() < 0) {
+ model_->MoveCursor(gfx::BreakType::LINE_BREAK,
+ gfx::VisualCursorDirection::CURSOR_LEFT, true);
+ } else if (drags_to_end && last_drag_location_.y() > height()) {
+ model_->MoveCursor(gfx::BreakType::LINE_BREAK,
+ gfx::VisualCursorDirection::CURSOR_RIGHT, true);
+ } else {
+ model_->MoveCursorTo(last_drag_location_, true);
+ }
+
if (aggregated_clicks_ == 1) {
model_->SelectWord();
// Expand the selection so the initially selected word remains selected.
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698