Skip to content

Commit a1a8669

Browse files
Simone Manganellirentzsch
Simone Manganelli
authored andcommitted
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 <[email protected]>
1 parent ea1a326 commit a1a8669

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Plugin/Plugin.m

+16-7
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,28 @@ - (void) drawRect:(NSRect)rect
261261
- (void) mouseDown:(NSEvent *)event
262262
{
263263
NSRect bounds = [ self bounds ];
264+
float viewWidth = bounds.size.width;
264265
float viewHeight = bounds.size.height;
265266
float margin = 5.0;
266267
float gearImageHeight = 16.0;
267268
float gearImageWidth = 16.0;
268269

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;
274272

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+
}
277286

278287
if (xCoordWithinGearImage && yCoordWithinGearImage) {
279288
[NSMenu popUpContextMenu:[self menuForEvent:event] withEvent:event forView:self];

0 commit comments

Comments
 (0)