10

I want to customize a NSMenu with NSMenuItems, so does it looks like the Apple Pro Apps.

But how can I customize a NSMenu? There is no draw method to change the appearance. If I set a NSView to a NSMenuItem, I can set the background color, but I will loose highlighting and menu handling. Furthermore the top and bottom cap of the NSMenu cannot be customized.

I found only this hint, but unfortunately without code.

Dark TableView with a white menu and white menu items

I would be very happy for some help!

JJD
  • 50,076
  • 60
  • 203
  • 339
Matt
  • 448
  • 5
  • 16
  • Did you successfully customize the NSMenu? – JJD Jan 31 '12 at 12:53
  • I found the [sources of NSMenu and others](http://sid.ethz.ch/debian/gnustep/gnustep-gui-0.20.0/Source/). Though, I could not find a useful hint there. – JJD Jan 31 '12 at 14:38
  • I wonder if it would be helpful to get the `MenuRef` with `_NSGetCarbonMenu()` as mentioned [in this thread](http://stackoverflow.com/questions/4064386/reverse-engineering-an-nsmenu-for-a-status-bar-item). – JJD Jan 31 '12 at 16:10
  • There is no solution for this. – Tim Feb 07 '12 at 21:52
  • 2
    Care to post a screenshot illustrating what you're trying to accomplish? – paulmelnikow Feb 09 '12 at 03:05
  • 2
    @JJD the sources you have found are for GNUStep - developed entirely independently to Apple's Cocoa, albeit aiming to implement the same api (well, aiming at some combo of OpenStep/modern Cocoa). It can be instructive to consider the GNUStep sources, but keep in mind undocumented cases, or even documented cases, may well behave differently. – Mark Feb 24 '12 at 10:31
  • There is a private method `_setHasPadding:onEdge:` that can be used to remove the top and bottom caps. – JWWalker Jan 20 '14 at 03:10

1 Answers1

2

The hard answer is, make your own, subclass NSMenu, NSMenuItem etc and manually handle the drawing, animations etc.

valexa
  • 4,462
  • 32
  • 48