diff options
author | Roopesh Chander <roop@roopc.net> | 2019-05-12 11:52:36 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2019-05-20 16:42:27 +0530 |
commit | 586a592b684dceedfc733283cf8930312f31e694 (patch) | |
tree | efb8fd2b402d3f75ebadf7625d24fae9ddb9a3cd | |
parent | macOS: Some menu item titles are automatically inferred (diff) | |
download | wireguard-apple-586a592b684dceedfc733283cf8930312f31e694.tar.xz wireguard-apple-586a592b684dceedfc733283cf8930312f31e694.zip |
macOS: Disable 'Delete Selected' when nothing is selected
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r-- | WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift | 9 |
1 files changed, 9 insertions, 0 deletions
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) |