0

Is there a way to customize the context menu that pops op when right clicking on a toolbar (or the title bar of the window containing it)? Several Apple applications (XCode, Safari, Mail and probably others seem to be able to remove or hide certain menu items), but I can't find a way to access the NSMenu.

Here's what I tried so far:

  • tried to get to the menu as I did on previous OS X versions (as explained here: How to customize the context menu of NSToolbar?): the returned NSMenu is nil
  • tried to override rightMouseDown: in the NSWindow containing the toolbar: the method is not called
  • tried to override menuForEvent: in the window's content view (I replaced the default content view with a custom NSView for this): the method is not called
  • tried to override rightMouseDown: in the window's content view (I replaced the default content view with a custom NSView for this): the method is not called

Any help would be greatly appreciated.

Community
  • 1
  • 1

1 Answers1

0

I actually found the answer by inspecting things in the debugger and tinkering a bit. On El Capitan, a working solution is to get the menu as such:

NSView * theContentView = myWindow.contentView;
NSMenu * theCustomizeMenu = theContentView.superview.menu;