From: Roopesh Chander Date: Sun, 12 May 2019 06:22:36 +0000 (+0530) Subject: macOS: Disable 'Delete Selected' when nothing is selected X-Git-Tag: 0.0.20190531-9~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=586a592b684dceedfc733283cf8930312f31e694;p=thirdparty%2Fwireguard-apple.git macOS: Disable 'Delete Selected' when nothing is selected Signed-off-by: Roopesh Chander --- 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)