Skip to content

Instantly share code, notes, and snippets.

@matthewreagan
Last active September 23, 2015 18:01
Show Gist options
  • Save matthewreagan/fb5a2138815fddd59561 to your computer and use it in GitHub Desktop.
Save matthewreagan/fb5a2138815fddd59561 to your computer and use it in GitHub Desktop.
Fixing control-click vs right-click contextual menus in NSView
- (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