Skip to content

Instantly share code, notes, and snippets.

@automactic
Created August 29, 2017 18:11
Show Gist options
  • Save automactic/9031785d77ac8b81ca78b8bb57fcf822 to your computer and use it in GitHub Desktop.
Save automactic/9031785d77ac8b81ca78b8bb57fcf822 to your computer and use it in GitHub Desktop.
macOS configSearchMenu
func configSearchMenu() {
let clear = NSMenuItem(title: "Clear", action: nil, keyEquivalent: "")
clear.tag = Int(NSSearchFieldClearRecentsMenuItemTag)
searchMenu.insertItem(clear, at: 0)
searchMenu.insertItem(NSMenuItem.separator(), at: 0)
let recents = NSMenuItem(title: "", action: nil, keyEquivalent: "")
recents.tag = Int(NSSearchFieldRecentsMenuItemTag)
searchMenu.insertItem(recents, at: 0)
let recentHeader = NSMenuItem(title: "Recent Search", action: nil, keyEquivalent: "")
recentHeader.tag = Int(NSSearchFieldRecentsTitleMenuItemTag)
searchMenu.insertItem(recentHeader, at: 0)
let noRecent = NSMenuItem(title: "No Recent Search", action: nil, keyEquivalent: "")
noRecent.tag = Int(NSSearchFieldNoRecentsMenuItemTag)
searchMenu.insertItem(noRecent, at: 0)
searchField.searchMenuTemplate = searchMenu
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment