I have an NSControl subclass (which is configured as a layer-hosting view, although I doubt that’s relevant). I’ve been attempting to write the code to get and display a context menu. However, neither menuForEvent: or rightMouseDown: are being called. Any idea what could be causing that? Other mouse events work correctly.
As an aside, I’m not sure if I have to call menuForEvent: myself, but the docs made it sound like I don’t, which is why I tried overriding it first. Regardless, I should at least expect rightMouseDown: to be called…
Related: it appears that AppKit doesn’t recognize Ctrl+Click as a right mouse click. Presumably I have to check for this condition in mouseDown: and call rightMouseDown: manually. But given the weirdness I’m seeing, is there some other way of doing it?
Have you included the
-(NSView *)hitTest:(NSPoint)aPointmethod in your subclass? It could be that the mouse event is being picked up by another element in your view and that would preventmenuForEventbeing called.You are correct in thinking that menuForEvent should be called automatically.