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

Unified Diff: ui/views/selection_controller.cc

Issue 2413223003: Views:: Make Labels support text selection. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 | « ui/views/examples/label_example.cc ('k') | ui/views/selection_controller_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/selection_controller.cc
diff --git a/ui/views/selection_controller.cc b/ui/views/selection_controller.cc
index 23e94823add559a08e535d2837cbc01c24913266..38ba6ed0a842bd6379753f00bac3ced72c3dae42 100644
--- a/ui/views/selection_controller.cc
+++ b/ui/views/selection_controller.cc
@@ -19,6 +19,11 @@ SelectionController::SelectionController(SelectionControllerDelegate* delegate)
: aggregated_clicks_(0),
delegate_(delegate),
handles_selection_clipboard_(false) {
+// On Linux, update the selection clipboard on a text selection.
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ set_handles_selection_clipboard(true);
+#endif
+
DCHECK(delegate);
}
@@ -32,12 +37,15 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event,
return true;
if (event.IsOnlyLeftMouseButton()) {
- delegate_->SetTextBeingDragged(false);
+ if (delegate_->SupportsDrag())
+ 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 +135,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 +182,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);
« no previous file with comments | « ui/views/examples/label_example.cc ('k') | ui/views/selection_controller_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698