Hi cocoa-dev, I have a custom UI component that wraps a number of subviews (mostly standard Cocoa views: NSTextField, NSImageView, etc.).
I'm attempting to provide a contextual menu for the entire top-level view / control in this case, so that regardless of which particular subview is right/control-clicked, the same menu can be shown. NSView by default does not call into super for -menuForEvent AFAICS, it just returns nil. The problem is easy to reproduce in a test app by adding e.g. an NSImageView to a custom container view subclass. The container view can provide a menu for -menuForEvent, which shows if the user control-clicks anywhere outside the child NSImageView. However a control click on the NSImageView shows nothing. (NOTE: right-click works in the above scenario, but a control-click does not.) My question: is there a simple Apple-prescribed approach for providing a single top-level contextual menu for a view *and* its subview tree for both right/control-click? I've found I can get this working with hacky approaches like traversing the view hierarchy and calling -setMenu on every subview, or overriding -menuForEvent on every single subview class, but this seems clunky and unnecessary. I also considered trying to solve this by leveraging -hitTest, but again, that seems like it shouldn't be required. Does anyone have any suggestions? Thanks, -matt _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com