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

Side by Side Diff: views/controls/link.cc

Issue 7248064: views: Override Label::HitTest with the default View::HitTest for Link. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/link.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/link.h" 5 #include "views/controls/link.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_LINUX) 9 #if defined(OS_LINUX)
10 #include <gdk/gdk.h> 10 #include <gdk/gdk.h>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (!IsEnabled()) 101 if (!IsEnabled())
102 return NULL; 102 return NULL;
103 #if defined(OS_WIN) 103 #if defined(OS_WIN)
104 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND); 104 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
105 return g_hand_cursor; 105 return g_hand_cursor;
106 #elif defined(OS_LINUX) 106 #elif defined(OS_LINUX)
107 return gfx::GetCursor(GDK_HAND2); 107 return gfx::GetCursor(GDK_HAND2);
108 #endif 108 #endif
109 } 109 }
110 110
111 bool Link::HitTest(const gfx::Point& l) const {
112 // We need to allow clicks on the link. So we override the implementation in
113 // Label and use the default implementation of View.
114 return View::HitTest(l);
115 }
116
111 bool Link::OnMousePressed(const MouseEvent& event) { 117 bool Link::OnMousePressed(const MouseEvent& event) {
112 if (!IsEnabled() || 118 if (!IsEnabled() ||
113 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) 119 (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton()))
114 return false; 120 return false;
115 SetHighlighted(true); 121 SetHighlighted(true);
116 return true; 122 return true;
117 } 123 }
118 124
119 bool Link::OnMouseDragged(const MouseEvent& event) { 125 bool Link::OnMouseDragged(const MouseEvent& event) {
120 SetHighlighted(IsEnabled() && 126 SetHighlighted(IsEnabled() &&
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } else { 219 } else {
214 if (font().GetStyle() & gfx::Font::UNDERLINED) { 220 if (font().GetStyle() & gfx::Font::UNDERLINED) {
215 Label::SetFont( 221 Label::SetFont(
216 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); 222 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED));
217 } 223 }
218 Label::SetColor(disabled_color_); 224 Label::SetColor(disabled_color_);
219 } 225 }
220 } 226 }
221 227
222 } // namespace views 228 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/link.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698