From 1dca1022d51d7249553c37748d83bf597f681ee4 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Sun, 12 May 2019 11:52:36 +0530 Subject: [PATCH] macOS: Disable 'Delete Selected' when nothing is selected --- .../ViewController/TunnelsListTableViewController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift index 982439d..f6d7790 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift @@ -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)