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

Unified Diff: ui/views/controls/label.cc

Issue 2650963002: MacViews: Select all text on right clicking an unfocused text view. (Closed)
Patch Set: Fix tests 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') | ui/views/controls/textfield/textfield.cc » ('J')
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 9b04c091ff1ab436580068f0d8a18cb0e9526562..70635fe94615d3f2f4b38750ec670f6d2822789c 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -509,6 +509,8 @@ bool Label::OnMousePressed(const ui::MouseEvent& event) {
if (!GetRenderTextForSelectionController())
return false;
+ const bool has_focus = HasFocus();
tapted 2017/01/25 09:11:16 optional: maybe had_focus?
karandeepb 2017/01/25 10:43:55 Done.
+
// 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
@@ -517,16 +519,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() && !has_focus) {
GetFocusManager()->SetFocusedView(this);
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- if (event.IsOnlyMiddleMouseButton() && GetFocusManager())
+ if (event.IsOnlyMiddleMouseButton() && GetFocusManager() && !has_focus)
GetFocusManager()->SetFocusedView(this);
#endif
- return selection_controller_->OnMousePressed(event, false);
+ return selection_controller_->OnMousePressed(
+ event, false, has_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') | ui/views/controls/textfield/textfield.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698