Technical Q&A QA1496

Configuring the Recent Searches menu for NSSearchField

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

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

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

New document that discusses the common problem when adding menu items to the Recent Searches menu.