diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 15:35:38 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 15:35:38 +0000 |
commit | 3d4560f45d650a9421eff15cd63f3e4b796f01f5 (patch) | |
tree | 1bed2441c7e4b1071adb3d22146f0726f80510cd /chrome/browser/cocoa/find_bar_view.mm | |
parent | d49e4a51428d0234d0dcbb11343315e4f2aa8fd6 (diff) | |
download | chromium_src-3d4560f45d650a9421eff15cd63f3e4b796f01f5.zip chromium_src-3d4560f45d650a9421eff15cd63f3e4b796f01f5.tar.gz chromium_src-3d4560f45d650a9421eff15cd63f3e4b796f01f5.tar.bz2 |
[Mac] Eat mouse clicks in the findbar to prevent them from falling through to views below.
BUG=http://crbug.com/22854
TEST=See test case in bug.
Review URL: http://codereview.chromium.org/273041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29281 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/find_bar_view.mm')
-rw-r--r-- | chrome/browser/cocoa/find_bar_view.mm | 63 |
1 files changed, 56 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/find_bar_view.mm b/chrome/browser/cocoa/find_bar_view.mm index 259d59d..93b0c0c 100644 --- a/chrome/browser/cocoa/find_bar_view.mm +++ b/chrome/browser/cocoa/find_bar_view.mm @@ -4,10 +4,13 @@ #import "chrome/browser/cocoa/find_bar_view.h" +namespace { +CGFloat kCurveSize = 8; +} // end namespace + @implementation FindBarView - (void)drawRect:(NSRect)rect { - CGFloat curveSize = 8; // TODO(rohitrao): Make this prettier. rect = NSInsetRect([self bounds], 0.5, 0.5); rect = NSOffsetRect(rect, 0, 1.0); @@ -15,17 +18,17 @@ NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); NSPoint midLeft1 = - NSMakePoint(NSMinX(rect) + curveSize, NSMaxY(rect) - curveSize); + NSMakePoint(NSMinX(rect) + kCurveSize, NSMaxY(rect) - kCurveSize); NSPoint midLeft2 = - NSMakePoint(NSMinX(rect) + curveSize, NSMinY(rect) + curveSize); + NSMakePoint(NSMinX(rect) + kCurveSize, NSMinY(rect) + kCurveSize); NSPoint midRight1 = - NSMakePoint(NSMaxX(rect) - curveSize, NSMinY(rect) + curveSize); + NSMakePoint(NSMaxX(rect) - kCurveSize, NSMinY(rect) + kCurveSize); NSPoint midRight2 = - NSMakePoint(NSMaxX(rect) - curveSize, NSMaxY(rect) - curveSize); + NSMakePoint(NSMaxX(rect) - kCurveSize, NSMaxY(rect) - kCurveSize); NSPoint bottomLeft = - NSMakePoint(NSMinX(rect) + (2 * curveSize), NSMinY(rect)); + NSMakePoint(NSMinX(rect) + (2 * kCurveSize), NSMinY(rect)); NSPoint bottomRight = - NSMakePoint(NSMaxX(rect) - (2 * curveSize), NSMinY(rect)); + NSMakePoint(NSMaxX(rect) - (2 * kCurveSize), NSMinY(rect)); NSBezierPath* path = [NSBezierPath bezierPath]; [path moveToPoint:topLeft]; @@ -60,4 +63,50 @@ [path stroke]; } +// The findbar is mostly opaque, but has an 8px transparent border on the left +// and right sides (see |kCurveSize|). This is an artifact of the way it is +// drawn. We override hitTest to return nil for points in this transparent +// area. +- (NSView*)hitTest:(NSPoint)point { + NSView* hitView = [super hitTest:point]; + if (hitView == self) { + // |rect| is approximately equivalent to the opaque area of the findbar. + NSRect rect = NSInsetRect([self bounds], kCurveSize, 0); + if (!NSMouseInRect(point, rect, [self isFlipped])) + return nil; + } + + return hitView; +} + +// Eat all mouse events, to prevent clicks from falling through to views below. +- (void)mouseDown:(NSEvent *)theEvent { +} + +- (void)rightMouseDown:(NSEvent *)theEvent { +} + +- (void)otherMouseDown:(NSEvent *)theEvent { +} + +- (void)mouseUp:(NSEvent *)theEvent { +} + +- (void)rightMouseUp:(NSEvent *)theEvent { +} + +- (void)otherMouseUp:(NSEvent *)theEvent { +} + +- (void)mouseMoved:(NSEvent *)theEvent { +} + +- (void)mouseDragged:(NSEvent *)theEvent { +} + +- (void)rightMouseDragged:(NSEvent *)theEvent { +} + +- (void)otherMouseDragged:(NSEvent *)theEvent { +} @end |