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

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, 10 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 if (!had_focus)
583 RequestFocus();
582 ShowImeIfNeeded(); 584 ShowImeIfNeeded();
583 } 585 }
584 586
585 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 587 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
586 if (!handled && !HasFocus() && event.IsOnlyMiddleMouseButton()) 588 if (!handled && !had_focus && event.IsOnlyMiddleMouseButton())
587 RequestFocus(); 589 RequestFocus();
588 #endif 590 #endif
589 591
590 return selection_controller_.OnMousePressed(event, handled); 592 return selection_controller_.OnMousePressed(
593 event, handled, had_focus ? SelectionController::FOCUSED
594 : SelectionController::UNFOCUSED);
591 } 595 }
592 596
593 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) { 597 bool Textfield::OnMouseDragged(const ui::MouseEvent& event) {
594 return selection_controller_.OnMouseDragged(event); 598 return selection_controller_.OnMouseDragged(event);
595 } 599 }
596 600
597 void Textfield::OnMouseReleased(const ui::MouseEvent& event) { 601 void Textfield::OnMouseReleased(const ui::MouseEvent& event) {
598 selection_controller_.OnMouseReleased(event); 602 selection_controller_.OnMouseReleased(event);
599 } 603 }
600 604
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 } 2057 }
2054 2058
2055 void Textfield::OnCursorBlinkTimerFired() { 2059 void Textfield::OnCursorBlinkTimerFired() {
2056 DCHECK(ShouldBlinkCursor()); 2060 DCHECK(ShouldBlinkCursor());
2057 gfx::RenderText* render_text = GetRenderText(); 2061 gfx::RenderText* render_text = GetRenderText();
2058 render_text->set_cursor_visible(!render_text->cursor_visible()); 2062 render_text->set_cursor_visible(!render_text->cursor_visible());
2059 RepaintCursor(); 2063 RepaintCursor();
2060 } 2064 }
2061 2065
2062 } // namespace views 2066 } // 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