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

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 2650963002: MacViews: Select all text on right clicking an unfocused text view. (Closed)
Patch Set: Nit Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/label.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } 568 }
569 569
570 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { 570 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) {
571 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); 571 bool in_selection = GetRenderText()->IsPointInSelection(event.location());
572 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; 572 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED;
573 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); 573 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection);
574 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; 574 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor;
575 } 575 }
576 576
577 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { 577 bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
578 const bool had_focus = HasFocus();
578 bool handled = controller_ && controller_->HandleMouseEvent(this, event); 579 bool handled = controller_ && controller_->HandleMouseEvent(this, event);
579 if (!handled && 580 if (!handled &&
580 (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton())) { 581 (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton())) {
581 RequestFocus(); 582 RequestFocus();
msw 2017/01/25 19:23:54 q: should this RequestFocus call also be in an if
karandeepb 2017/01/27 02:29:37 Done. Though this shouldn't matter anyway, Request
582 ShowImeIfNeeded(); 583 ShowImeIfNeeded();
583 } 584 }
584 585
585 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 586 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
586 if (!handled && !HasFocus() && event.IsOnlyMiddleMouseButton()) 587 if (!handled && !had_focus && event.IsOnlyMiddleMouseButton())
587 RequestFocus(); 588 RequestFocus();
588 #endif 589 #endif
589 590
590 return selection_controller_.OnMousePressed(event, handled); 591 return selection_controller_.OnMousePressed(
592 event, handled, had_focus ? SelectionController::FOCUSED
593 : SelectionController::UNFOCUSED);
591 } 594 }
592 595
593 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) { 596 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) {
594 return selection_controller_.OnMouseDragged(event); 597 return selection_controller_.OnMouseDragged(event);
595 } 598 }
596 599
597 void Textfield::OnMouseReleased(const ui::MouseEvent& event) { 600 void Textfield::OnMouseReleased(const ui::MouseEvent& event) {
598 selection_controller_.OnMouseReleased(event); 601 selection_controller_.OnMouseReleased(event);
599 } 602 }
600 603
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 } 2056 }
2054 2057
2055 void Textfield::OnCursorBlinkTimerFired() { 2058 void Textfield::OnCursorBlinkTimerFired() {
2056 DCHECK(ShouldBlinkCursor()); 2059 DCHECK(ShouldBlinkCursor());
2057 gfx::RenderText* render_text = GetRenderText(); 2060 gfx::RenderText* render_text = GetRenderText();
2058 render_text->set_cursor_visible(!render_text->cursor_visible()); 2061 render_text->set_cursor_visible(!render_text->cursor_visible());
2059 RepaintCursor(); 2062 RepaintCursor();
2060 } 2063 }
2061 2064
2062 } // namespace views 2065 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698