Ver código fonte

Only enable delete menu item for root nodes

master
Shadowfacts 4 meses atrás
pai
commit
9e258b71f4
Acessado por: Shadowfacts <me@shadowfacts.net> ID da chave GPG: 94A5AB95422746E5

+ 5
- 1
MongoView/View Controllers/QueryViewController.swift Ver arquivo

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

Carregando…
Cancelar
Salvar