I have a macOS app written in objective-c. Initially, I didn't want to provide a Help menu, so I removed the 'Help' top-level menu item from the storyboard.
Now I want to add a help facility, and still retain the system-provided menu search bar. I have added the Help menu and the submenu items needed for my app. But the search bar does not appear.
This is the menu search behavior that I am looking for:
When I add the Help menu item and submenu items back into my app via the storyboard, the search bar does not appear when I run the app. Is there some magic necessary to enable this behavior?
This seems to resolve the issue. First, I assigned a value to the tag in the NSMenuItem titled 'Help', defining its value as TAG_HELP_MENU. Then, I added this code to the AppDelegate.h file, within the method applicationDidFinishLaunching:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSMenu *menu = NSApplication.sharedApplication.mainMenu;
for (NSMenuItem *item in menu.itemArray)
{
if (item.tag == TAG_HELP_MENU)
{
NSApplication.sharedApplication.helpMenu = item.submenu;
}
}
return;
}
Now, I get the behavior I was looking for.