Chromium Code Reviews| Index: ui/views/selection_controller.cc |
| diff --git a/ui/views/selection_controller.cc b/ui/views/selection_controller.cc |
| index 38ba6ed0a842bd6379753f00bac3ced72c3dae42..b183ea1ff9586b95e0114eed88fbe0087457b7b5 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,13 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event, |
| } |
| } |
| + 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()); |
|
tapted
2016/12/19 06:49:16
There's another NSTextField behaviour related to t
karandeepb
2016/12/19 07:05:43
Yeah had pointed this out in the comment with the
tapted
2016/12/20 00:12:42
I couldn't find this comment - can you send me a l
karandeepb
2016/12/21 14:20:02
I was referring to the comment with the initial PT
|
| + |
| if (handles_selection_clipboard_ && event.IsOnlyMiddleMouseButton()) { |
| if (render_text->IsPointInSelection(event.location())) { |
| delegate_->OnBeforePointerAction(); |
| @@ -92,6 +96,15 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event, |
| return true; |
| } |
| +void SelectionController::SelectWord(const gfx::Point& point) { |
| + 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 |