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

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-01-03 23:16:44 +05:30
parent a221cb566b
commit de12c27d5b
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 {