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

Unified Diff: ui/views/controls/label.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 | « no previous file | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index a047acbd51c35cdec04f00955df331f2eda11563..2086222e63f3c879d426a3d4509f7f2ec612a0d8 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -513,6 +513,8 @@ bool Label::OnMousePressed(const ui::MouseEvent& event) {
if (!GetRenderTextForSelectionController())
return false;
+ const bool had_focus = HasFocus();
+
// RequestFocus() won't work when the label has FocusBehavior::NEVER. Hence
// explicitly set the focused view.
// TODO(karandeepb): If a widget with a label having FocusBehavior::NEVER as
@@ -521,16 +523,18 @@ bool Label::OnMousePressed(const ui::MouseEvent& event) {
// when the widget gets focus again. Fix this.
// Tracked in https://crbug.com/630365.
if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
- GetFocusManager()) {
+ GetFocusManager() && !had_focus) {
GetFocusManager()->SetFocusedView(this);
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- if (event.IsOnlyMiddleMouseButton() && GetFocusManager())
+ if (event.IsOnlyMiddleMouseButton() && GetFocusManager() && !had_focus)
GetFocusManager()->SetFocusedView(this);
#endif
- return selection_controller_->OnMousePressed(event, false);
+ return selection_controller_->OnMousePressed(
+ event, false, had_focus ? SelectionController::FOCUSED
+ : SelectionController::UNFOCUSED);
}
bool Label::OnMouseDragged(const ui::MouseEvent& event) {
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698