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

Unified Diff: ui/views/selection_controller.cc

Issue 2413223003: Views:: Make Labels support text selection. (Closed)
Patch Set: -- Created 4 years, 2 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: ui/views/selection_controller.cc
diff --git a/ui/views/selection_controller.cc b/ui/views/selection_controller.cc
index 23e94823add559a08e535d2837cbc01c24913266..6fa77d434baec39b87b71a08c240586774bf13d6 100644
--- a/ui/views/selection_controller.cc
+++ b/ui/views/selection_controller.cc
@@ -32,12 +32,15 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event,
return true;
if (event.IsOnlyLeftMouseButton()) {
- delegate_->SetTextBeingDragged(false);
+ if (delegate_->SupportsDrag())
msw 2016/10/28 06:30:26 Is this just disabling something that otherwise wo
karandeepb 2016/11/01 11:06:25 To support dragging selected text, Labels would ne
+ delegate_->SetTextBeingDragged(false);
+
switch (aggregated_clicks_) {
case 0:
// If the click location is within an existing selection, it may be a
// potential drag and drop.
- if (render_text->IsPointInSelection(event.location())) {
+ if (delegate_->SupportsDrag() &&
+ render_text->IsPointInSelection(event.location())) {
delegate_->SetTextBeingDragged(true);
} else {
delegate_->OnBeforePointerAction();
@@ -127,7 +130,9 @@ void SelectionController::OnMouseReleased(const ui::MouseEvent& event) {
render_text->MoveCursorTo(event.location(), false);
delegate_->OnAfterPointerAction(false, selection_changed);
}
- delegate_->SetTextBeingDragged(false);
+
+ if (delegate_->SupportsDrag())
+ delegate_->SetTextBeingDragged(false);
if (handles_selection_clipboard_ && !render_text->selection().is_empty())
delegate_->UpdateSelectionClipboard();
@@ -172,7 +177,7 @@ void SelectionController::SelectThroughLastDragLocation() {
delegate_->OnBeforePointerAction();
// TODO(karandeepb): See if this can be handled at the RenderText level.
- const bool drags_to_end = PlatformStyle::kTextfieldDragVerticallyDragsToEnd;
+ const bool drags_to_end = PlatformStyle::kTextDragVerticallyDragsToEnd;
if (drags_to_end && last_drag_location_.y() < 0) {
render_text->MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT,
gfx::SELECTION_RETAIN);

Powered by Google App Engine
This is Rietveld 408576698