Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove (or customize) 'Search' from help menu

My app has the default 'Help' menu. I have removed the 'Help' entry and added a Support entry that links to a forum on my website.

The help menu nib looks like this:

Menu in nib

But once I have the app up and running a new menu item has been suck in:

Menu with search

How can I make the search go away? (Or even better, how could I make it launch a url with params such as http://mywebsite.com/support?search=XXXXX).

like image 906
Kyle Avatar asked Feb 27 '14 17:02

Kyle


4 Answers

I have found the way to remove the search bar (but not to customize it).

Just assign a menu that is not used to the help menu:

NSMenu *unusedMenu;
unusedMenu = [[NSMenu alloc] initWithTitle:@"Unused"];

NSApplication *theApp;
theApp = [NSApplication sharedApplication];
theApp.helpMenu = unusedMenu;

The documentation mentions this in the helpMenu property of the NSApplication class.

like image 175
zhoudu Avatar answered Oct 07 '22 11:10

zhoudu


You're looking for NSUserInterfaceItemSearching protocol. Return a single search result item and use it to open your custom URL.

- (void)searchForItemsWithSearchString:(NSString *)searchString resultLimit:(NSInteger)resultLimit matchedItemHandler:(void (^)(NSArray *items))handleMatchedItems
{
    handleMatchedItems(@[searchString]);
}

- (NSArray *)localizedTitlesForItem:(id)item
{
    return @[[NSString stringWithFormat:@"Search for '%@' on my website", [item description]]];
}

- (void)performActionForItem:(id)item
{
    // Open your custom url assuming item is actually searchString
}
like image 29
pointum Avatar answered Oct 07 '22 10:10

pointum


You probably don't want to get rid of that search bar, since you can still use it to search for menu items!

Searching for Menu Items

As I'm sure you know, this search box will only show Help Topics if your app comes with an Apple Help Book, which can be made by following Apple's documentation.

I'm afraid I don't know of a way to override the search bar's behaviour, but if you don't want to write documentation for your app, I think it would be better to keep the search bar, even if you can't search your forum for help.

like image 31
Ben Avatar answered Oct 07 '22 11:10

Ben


I remove Search bar from Help menu in mac development by enter a single Space after Help like "help ".Its look funny but working properly.

enter image description here

like image 45
user7345678 Avatar answered Oct 07 '22 12:10

user7345678