I need to use a custom NSView
subclass to draw some content, but it isn't drawing as highlighted when the user hovers and it doesn't dismiss the NSMenu
when the user clicks on it. Any ideas?
So using -drawRect:
and [[self enclosingMenuItem] isHighlighted]
I'm able to tell whether or not I need to draw the view as highlighted and am given the chance to do so. All I have to figure out is how to do that.
Maybe you should try it this way:
#define menuItem ([self enclosingMenuItem])
- (void) drawRect: (NSRect) rect {
BOOL isHighlighted = [menuItem isHighlighted];
if (isHighlighted) {
[[NSColor selectedMenuItemColor] set];
[NSBezierPath fillRect:rect];
} else {
[super drawRect: rect];
}
}