Hook up new search toolbar item
This commit is contained in:
parent
656d327692
commit
8ee33c34b3
|
@ -764,11 +764,20 @@ extension MainWindowController: NSToolbarDelegate {
|
||||||
button.sendAction(on: .leftMouseDown)
|
button.sendAction(on: .leftMouseDown)
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.itemIdentifier == .search, let searchField = item.view as? NSSearchField {
|
if #available(macOS 10.16, *) {
|
||||||
searchField.delegate = self
|
if item.itemIdentifier == .search, let searchItem = item as? NSSearchToolbarItem {
|
||||||
searchField.target = self
|
searchItem.searchField.delegate = self
|
||||||
searchField.action = #selector(runSearch(_:))
|
searchItem.searchField.target = self
|
||||||
currentSearchField = searchField
|
searchItem.searchField.action = #selector(runSearch(_:))
|
||||||
|
currentSearchField = searchItem.searchField
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if item.itemIdentifier == .search, let searchField = item.view as? NSSearchField {
|
||||||
|
searchField.delegate = self
|
||||||
|
searchField.target = self
|
||||||
|
searchField.action = #selector(runSearch(_:))
|
||||||
|
currentSearchField = searchField
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,13 +786,23 @@ extension MainWindowController: NSToolbarDelegate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.itemIdentifier == .search, let searchField = item.view as? NSSearchField {
|
if #available(macOS 10.16, *) {
|
||||||
searchField.delegate = nil
|
if item.itemIdentifier == .search, let searchItem = item as? NSSearchToolbarItem {
|
||||||
searchField.target = nil
|
searchItem.searchField.delegate = nil
|
||||||
searchField.action = nil
|
searchItem.searchField.target = nil
|
||||||
currentSearchField = nil
|
searchItem.searchField.action = nil
|
||||||
|
currentSearchField = nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if item.itemIdentifier == .search, let searchField = item.view as? NSSearchField {
|
||||||
|
searchField.delegate = nil
|
||||||
|
searchField.target = nil
|
||||||
|
searchField.action = nil
|
||||||
|
currentSearchField = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
Loading…
Reference in New Issue