@@ -261,19 +261,28 @@ - (void) drawRect:(NSRect)rect
261
261
- (void ) mouseDown : (NSEvent *)event
262
262
{
263
263
NSRect bounds = [ self bounds ];
264
+ float viewWidth = bounds.size .width ;
264
265
float viewHeight = bounds.size .height ;
265
266
float margin = 5.0 ;
266
267
float gearImageHeight = 16.0 ;
267
268
float gearImageWidth = 16.0 ;
268
269
269
- NSPoint mouseLocation = [event locationInWindow ];
270
- NSPoint localMouseLocation = [self convertPoint: mouseLocation fromView: nil ];
271
-
272
- BOOL xCoordWithinGearImage = ( (localMouseLocation.x >= (0 + margin)) &&
273
- (localMouseLocation.x <= (0 + margin + gearImageWidth)) );
270
+ BOOL xCoordWithinGearImage = NO ;
271
+ BOOL yCoordWithinGearImage = NO ;
274
272
275
- BOOL yCoordWithinGearImage = ( (localMouseLocation.y >= (viewHeight - margin - gearImageHeight)) &&
276
- (localMouseLocation.y <= (viewHeight - margin)) );
273
+ // if the view is 32 pixels or smaller in either direction,
274
+ // the gear image is not drawn, so we shouldn't pop-up the contextual
275
+ // menu on a single-click either
276
+ if ( (viewWidth > 32 ) && (viewHeight > 32 ) ) {
277
+ NSPoint mouseLocation = [event locationInWindow ];
278
+ NSPoint localMouseLocation = [self convertPoint: mouseLocation fromView: nil ];
279
+
280
+ xCoordWithinGearImage = ( (localMouseLocation.x >= (0 + margin)) &&
281
+ (localMouseLocation.x <= (0 + margin + gearImageWidth)) );
282
+
283
+ yCoordWithinGearImage = ( (localMouseLocation.y >= (viewHeight - margin - gearImageHeight)) &&
284
+ (localMouseLocation.y <= (viewHeight - margin)) );
285
+ }
277
286
278
287
if (xCoordWithinGearImage && yCoordWithinGearImage) {
279
288
[NSMenu popUpContextMenu: [self menuForEvent: event] withEvent: event forView: self ];
0 commit comments