macOS: Disable 'Delete Selected' when nothing is selected

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-05-12 11:52:36 +05:30
parent c0526d2efb
commit 586a592b68
1 changed files with 9 additions and 0 deletions

View 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 { class FillerButton: NSButton {
override var intrinsicContentSize: NSSize { override var intrinsicContentSize: NSSize {
return NSSize(width: NSView.noIntrinsicMetric, height: NSView.noIntrinsicMetric) return NSSize(width: NSView.noIntrinsicMetric, height: NSView.noIntrinsicMetric)