Permalink
Browse files

if gear image isn't drawn on a CtF view, the contextual menu no longe…

…r 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 <jwr.git@redshed.net>
  • Loading branch information...
1 parent ea1a326 commit a1a86695294ac7f633a6b6f68b574d18e1ec0926 Simone Manganelli committed with Apr 21, 2009
Showing with 16 additions and 7 deletions.
  1. +16 −7 Plugin/Plugin.m
View
23 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];

0 comments on commit a1a8669

Please sign in to comment.