Pergunta

This is a simple question...

Just: How would I go about subclassing NSMenu? As I'm not sure about how to go about doing it.

I'd like to subclass it in order to do custom drawing eg. change background colour etc.

This is normally done with - (void)drawRect:(NSRect)dirtyRect thus I tried subclassing and using that method, to no avail.

Foi útil?

Solução

You can't do this by subclassing NSMenu. You want to use NSMenuItem's setView: to do custom drawing in a menu. Take a look at the MenuItemView sample code for an example of how it's done and what you can do with it.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top