macOS: Manage tunnels: Select first tunnel on showing the window

This commit is contained in:
Roopesh Chander 2019-01-03 23:16:44 +05:30
parent 14fa8530d7
commit fda8a5d83b
1 changed files with 8 additions and 0 deletions

View File

@ -61,6 +61,7 @@ class TunnelsListTableViewController: NSViewController {
override func loadView() {
tableView.dataSource = self
tableView.delegate = self
selectFirstTunnel()
let scrollView = NSScrollView()
scrollView.hasVerticalScroller = true
@ -148,6 +149,13 @@ class TunnelsListTableViewController: NSViewController {
@objc func exportTunnelsClicked() {
print("exportTunnelsClicked")
}
@discardableResult
private func selectFirstTunnel() -> Bool {
guard tunnelsManager.numberOfTunnels() > 0 else { return false }
tableView.selectRowIndexes(IndexSet(integer: 0), byExtendingSelection: false)
return true
}
}
extension TunnelsListTableViewController: NSTableViewDataSource {