Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
Simone Manganelli authored and rentzsch committed Apr 22, 2009
1 parent ea1a326 commit a1a8669
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Plugin/Plugin.m
Expand Up @@ -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];
Expand Down

0 comments on commit a1a8669

Please sign in to comment.