i try use custom view nsmenuitem
, works. unfortunately, have difficulties highlighting (mouseover). followed instructions in other threads implement drawrect:
in nsview
subclass blue highlighting manually. seems work, highlighting color not correct. appears dark compared regular menu items , interestingly subviews
of custom view use correct highlighting color (see screenshot). ideas on how fix issue?
my current drawrect:
method in nsview
subclass looks this:
- (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 highlighting looks like:
Comments
Post a Comment