From a1a86695294ac7f633a6b6f68b574d18e1ec0926 Mon Sep 17 00:00:00 2001 From: Simone Manganelli Date: Wed, 22 Apr 2009 04:04:11 +0800 Subject: [PATCH] if gear image isn't drawn on a CtF view, the contextual menu no longer pops up if you click in the upper-left corner of the view (as it should have done from the start *facepalm*) Signed-off-by: Jonathan 'Wolf' Rentzsch --- Plugin/Plugin.m | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) 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];