Remove (or customize) 'Search' from help menu

左心房为你撑大大i 提交于 2019-12-04 09:21:46

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
}

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.

You probably don't want to get rid of that search bar, since you can still use it to search 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.

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!