views:

20

answers:

1

I tried to overwrite the simple NSView method:

- (NSMenu *)menuForEvent:(NSEvent *)event {
   NSMenu* result = [super menuForEvent: event];
   NSMenuItem* mi = [[NSMenuItem alloc] initWithTitle: @"Foobar" action: @selector(foobar) keyEquivalent: @""];
   [result addItem: mi];    
   return result;
}

but it does not work. It is never called.

A: 

If the text field has focus, I believe the menu you're getting is actually that of the Field Editor. Maybe ask it for its menu.

Joshua Nozzi