I am trying to use a custom view for NSMenuitem that works. Unfortunately, I have some difficulties with mouseover. I have already followed instructions in other threads to implement drawRect: in my NSView subclass, to do the blue highlighting manually. This seems to work, but the backlight color is incorrect. It seems too dark compared to regular menu items, and it is interesting that the subviews my user view use the correct highlight color (see screenshot). Any ideas on how to fix this?
My current drawRect: method in a subclass of NSView as follows:
- (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; BOOL isHighlighted = [[self enclosingMenuItem] isHighlighted]; if (isHighlighted) { [[NSColor selectedMenuItemColor] setFill]; NSRectFill(dirtyRect); [self.profileNameView setTextColor:[NSColor whiteColor]]; [self.securedIPView setTextColor:[NSColor whiteColor]]; [self.separatorView setTextColor:[NSColor whiteColor]]; [self.connectionTimeView setTextColor:[NSColor whiteColor]]; } else { [self.profileNameView setTextColor:[NSColor controlTextColor]]; [self.securedIPView setTextColor:[NSColor disabledControlTextColor]]; [self.separatorView setTextColor:[NSColor disabledControlTextColor]]; [self.connectionTimeView setTextColor:[NSColor disabledControlTextColor]]; } }
The resulting highlight is as follows:

source share