diff --git a/Plugin/Plugin.m b/Plugin/Plugin.m index 9e014017..c869dcac 100644 --- a/Plugin/Plugin.m +++ b/Plugin/Plugin.m @@ -261,19 +261,28 @@ - (void) drawRect:(NSRect)rect - (void) mouseDown:(NSEvent *)event { NSRect bounds = [ self bounds ]; + float viewWidth = bounds.size.width; float viewHeight = bounds.size.height; float margin = 5.0; float gearImageHeight = 16.0; float gearImageWidth = 16.0; - NSPoint mouseLocation = [event locationInWindow]; - NSPoint localMouseLocation = [self convertPoint:mouseLocation fromView:nil]; - - BOOL xCoordWithinGearImage = ( (localMouseLocation.x >= (0 + margin)) && - (localMouseLocation.x <= (0 + margin + gearImageWidth)) ); + BOOL xCoordWithinGearImage = NO; + BOOL yCoordWithinGearImage = NO; - BOOL yCoordWithinGearImage = ( (localMouseLocation.y >= (viewHeight - margin - gearImageHeight)) && - (localMouseLocation.y <= (viewHeight - margin)) ); + // if the view is 32 pixels or smaller in either direction, + // the gear image is not drawn, so we shouldn't pop-up the contextual + // menu on a single-click either + if ( (viewWidth > 32) && (viewHeight > 32) ) { + NSPoint mouseLocation = [event locationInWindow]; + NSPoint localMouseLocation = [self convertPoint:mouseLocation fromView:nil]; + + xCoordWithinGearImage = ( (localMouseLocation.x >= (0 + margin)) && + (localMouseLocation.x <= (0 + margin + gearImageWidth)) ); + + yCoordWithinGearImage = ( (localMouseLocation.y >= (viewHeight - margin - gearImageHeight)) && + (localMouseLocation.y <= (viewHeight - margin)) ); + } if (xCoordWithinGearImage && yCoordWithinGearImage) { [NSMenu popUpContextMenu:[self menuForEvent:event] withEvent:event forView:self];