Configuring the Recent Searches menu for NSSearchField

Q: Why are my menu items disabled in the Recent Searches menu of NSSearchField?

A: You are probably not providing an action selector to your menu items. When you add Search Categories to the Recent Searches menu, you are responsible for providing the "action" selector.

Here is how you would programatically build a menu item to be added:

Listing 1: Example menu item

NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"Client Search"
                                         action:@selector(clientSearchAction:)
                                         keyEquivalent:@""];

If you are using Interface Builder to configure your Recent Searches menu, you must connect the menu item to the appropriate action selector in your controller object.

For a complete code example, refer to:

Introduction to Search Fields: Configuring a Search Menu

Document Revision History

DateNotes
2006-11-27First Version

Posted: 2006-11-27


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.