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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index d15a3e3d915441064cae5a4ae29dadb8afbbdca2..3a417b19029a1274367a2506e6d39bf139e9d010 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -575,19 +575,23 @@ gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) {
}
bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
+ const bool had_focus = HasFocus();
bool handled = controller_ && controller_->HandleMouseEvent(this, event);
if (!handled &&
(event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton())) {
- RequestFocus();
+ if (!had_focus)
+ RequestFocus();
ShowImeIfNeeded();
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- if (!handled && !HasFocus() && event.IsOnlyMiddleMouseButton())
+ if (!handled && !had_focus && event.IsOnlyMiddleMouseButton())
RequestFocus();
#endif
- return selection_controller_.OnMousePressed(event, handled);
+ return selection_controller_.OnMousePressed(
+ event, handled, had_focus ? SelectionController::FOCUSED
+ : SelectionController::UNFOCUSED);
}
bool Textfield::OnMouseDragged(const ui::MouseEvent& event) {
« 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