ContextMenu with custom font/color + indentation

Hi,

I just wanted to share the code as I was especially looking for a contextual menu using a small font size and “group titles” instead of separator lines.
I’ve used the NSMenu “setFont” declares before but it did not result smaller menu only the font it self was smaller. The way to go is using an attributed string.

(image shows default menu item font style but size set to 12.0 (instead of 14.0)

(size=14.0)

https://www.dropbox.com/s/eb79rjvjzxt3dic/Menu_Indentation_Font_Color.xojo_binary_project?dl=0

My best guess would have been that you need to assign an NSView to NSMenuItem’s view property. Then you can achieve anything you want in a menu. But yours is more elegant for text only stuff.

That involves to much work as you need to manage the NSView and all that drawing stuff. The solution as posted initially is totally fine for it. I think the topic may be misleading a bit as I already found a solution.