Only enable delete menu item for root nodes

This commit is contained in:
Shadowfacts 2020-04-04 13:28:25 -04:00
parent b971952217
commit 9e258b71f4
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 5 additions and 1 deletions

View File

@ -173,7 +173,11 @@ class QueryViewController: NSViewController {
extension QueryViewController: NSMenuItemValidation { extension QueryViewController: NSMenuItemValidation {
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool { func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
if menuItem.action == #selector(deleteNode(_:)) { if menuItem.action == #selector(deleteNode(_:)) {
return outlineView.clickedRow != -1 if outlineView.clickedRow != -1, let node = outlineView.item(atRow: outlineView.clickedRow) as? Node, node.parent == nil {
return true
} else {
return false
}
} }
return true return true
} }