Last active
September 23, 2015 18:01
-
-
Save matthewreagan/fb5a2138815fddd59561 to your computer and use it in GitHub Desktop.
Fixing control-click vs right-click contextual menus in NSView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)mouseDown:(NSEvent *)theEvent | |
{ | |
/* Hard-coding this behavior isn't great, and shouldn't be necessary. (It should | |
be up to OS X to define what a contextual-menu click is/isn't, and we should | |
only care about vending our NSMenu via `menuForEvent:`). But this fixes the | |
discrepancy between control and right clicks in NSView. */ | |
if ((theEvent.modifierFlags & NSControlKeyMask)) | |
{ | |
[NSMenu popUpContextMenu:[self menuForEvent:theEvent] withEvent:theEvent forView:self]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment