I want to customize an an NSPopUpButton so I have implemented an CustomMenuItemView which right now only has the following code (for testing purposes):
- (void)drawRect:(NSRect)dirtyRect
{
[[NSColor redColor] set];
NSRectFill(dirtyRect);
}
Now, for every NSMenuItem i add to the NSMenu in myPopUpButton.menu I set the view to my custom view:
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Some title" action:NULL keyEquivalent:@""];
menuItem.view = [[CustomMenuItemView alloc] initWithFrame:NSMakeRect(0, 0, 100, 25)];
When I run my program and open the popup button the menuitem selection seems disabled (i.e. nothing happens when I click on it).
I am guessing that it is not actually disabled; it just doesn't respond to events anymore. Do I need to add some event handling in my custom view? If so, how?
I solved the problem by adding the
mouseUpmethod to myCustomMenuItemView: