views:

187

answers:

1

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: http://osdir.com/ml/cocoa-dev/2009-06/msg00426.html

I would be very happy for some help!

A: 

Without a screenshot as to what these pro app menus look like it's hard to help you out. Complex menus are sometimes implemented as custom windows.

Matt Gemmell has some open source components that may be useful. Particularly MAAttachedWindow.

Matthieu Cormier
Thank you for your reply. If I use a window, I have to implement all menu handling functions. I thought there is a way to customize a NSMenu by subclassing!?Here is a screenshot where you can see what I mean:http://img145.yfrog.com/i/bildschirmfoto20100331u.png/
Matt
Most likely, Apple is doing that by subclassing an internal class that is not accessible from the public API. You will have to build something from scratch if you want to emulate that look.
Matthieu Cormier
Or they're using some underlying Carbon HI API directly. It's not necessarily possible to do everything with Cocoa (although at this stage most things are possible).
quixoto