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

Unified Diff: ui/views/selection_controller.cc

Issue 2580293003: MacViews: Select word under cursor on right click. (Closed)
Patch Set: Add TODO Created 4 years 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/selection_controller.h ('k') | ui/views/style/platform_style.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 38ba6ed0a842bd6379753f00bac3ced72c3dae42..d34a36acf0551225f183f16ba856f8652e223c76 100644
--- a/ui/views/selection_controller.cc
+++ b/ui/views/selection_controller.cc
@@ -56,10 +56,7 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event,
break;
case 1:
// Select the word at the click location on a double click.
- delegate_->OnBeforePointerAction();
- render_text->MoveCursorTo(event.location(), false);
- render_text->SelectWord();
- delegate_->OnAfterPointerAction(false, true);
+ SelectWord(event.location());
double_click_word_ = render_text->selection();
break;
case 2:
@@ -73,6 +70,15 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event,
}
}
+ // TODO(crbug.com/676296): Right clicking an unfocused text view should select
+ // all its text on Mac.
+ const bool select_word_on_right_click =
+ event.IsOnlyRightMouseButton() &&
+ PlatformStyle::kSelectWordOnRightClick &&
+ !render_text->IsPointInSelection(event.location());
+ if (select_word_on_right_click)
+ SelectWord(event.location());
+
if (handles_selection_clipboard_ && event.IsOnlyMiddleMouseButton()) {
if (render_text->IsPointInSelection(event.location())) {
delegate_->OnBeforePointerAction();
@@ -92,6 +98,15 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event,
return true;
}
+void SelectionController::SelectWord(const gfx::Point& point) {
tapted 2016/12/22 05:34:46 nit: reorder to match header (between TrackMouseCl
karandeepb 2016/12/22 08:51:25 Done.
+ gfx::RenderText* render_text = GetRenderText();
+ DCHECK(render_text);
+ delegate_->OnBeforePointerAction();
+ render_text->MoveCursorTo(point, false);
+ render_text->SelectWord();
+ delegate_->OnAfterPointerAction(false, true);
+}
+
bool SelectionController::OnMouseDragged(const ui::MouseEvent& event) {
DCHECK(GetRenderText());
// If |drag_selection_timer_| is running, |last_drag_location_| will be used
« no previous file with comments | « ui/views/selection_controller.h ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698