What I want to do is put a NSTextField as a menu extra. So in my nib I put a custom view down, placed a NSTextField in it, and hooked it all up to my controller object. In the controller's awakeFromNib method, it does the following:
Code:
- (void)awakeFromNib
{
NSStatusBar *bar = [NSStatusBar systemStatusBar];
theItem = [bar statusItemWithLength:NSVariableStatusItemLength];
[theItem retain];
[theItem setView:theView];
[theItem setHighlightMode:YES];
[searchField setEnabled:YES];
}
By the way, I declared theItem to be a NSStatusItem in the header. When I run it, it places the view with the text field in the menu bar just like I want it to, but the NSTextField can't get focused, so it's not really useful. Is there anything I can do to make that work? Maybe make a subclass of NSTextField or NSView and use that?