]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
macOS: Disable 'Delete Selected' when nothing is selected
authorRoopesh Chander <roop@roopc.net>
Sun, 12 May 2019 06:22:36 +0000 (11:52 +0530)
committerRoopesh Chander <roop@roopc.net>
Mon, 20 May 2019 11:12:27 +0000 (16:42 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift

index 982439dda7aa9067dd6290f2fd006a30c49819a4..f6d779052aaa2448148e6266cf24cd0f40d0b6d6 100644 (file)
@@ -317,6 +317,15 @@ extension TunnelsListTableViewController {
     }
 }
 
+extension TunnelsListTableViewController: NSMenuItemValidation {
+    func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
+        if menuItem.action == #selector(TunnelsListTableViewController.handleRemoveTunnelAction) {
+            return !tableView.selectedRowIndexes.isEmpty
+        }
+        return true
+    }
+}
+
 class FillerButton: NSButton {
     override var intrinsicContentSize: NSSize {
         return NSSize(width: NSView.noIntrinsicMetric, height: NSView.noIntrinsicMetric)