Control + Do not start menu menuForEvent

That's it. So, I have a subclass NSBox, and it has subviews as a shortcut and two imageViews. I redefined menuForEvent:. However, when I click on NSBoxto select it, and then later Control + Click on any of my subzones, then it is menuForEvent:never called.

I do not understand why this is so.

+5
source share
2 answers

There is a difference in how control clicks and right-clicks are handled by NSView (as jfewtr pointed out). Context menus will appear for the right mouse button if a click gets into the preview, but not for the control .

: NSView control-click quirks

, / , , . , , ( NSBox) :

- (void)mouseDown:(NSEvent *)theEvent
{
    if (theEvent.modifierFlags & NSControlKeyMask)
    {
        [NSMenu popUpContextMenu:[self menuForEvent:theEvent] withEvent:theEvent forView:self];
    }
}

, , /.

+4

menuForEvent: , ( NSBox) menuForEvent:

- (NSMenu *)menuForEvent:(NSEvent *)event
{
    return [[self superview] menuForEvent:event];
}

, . , , - .

+1

All Articles