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.
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.