aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController/ButtonedDetailViewController.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/ViewController/ButtonedDetailViewController.swift')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/ButtonedDetailViewController.swift48
1 files changed, 48 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/ButtonedDetailViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/ButtonedDetailViewController.swift
new file mode 100644
index 00000000..defa09fd
--- /dev/null
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/ButtonedDetailViewController.swift
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: MIT
+// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.
+
+import Cocoa
+
+class ButtonedDetailViewController: NSViewController {
+
+ var onButtonClicked: (() -> Void)?
+
+ let button: NSButton = {
+ let button = NSButton()
+ button.title = ""
+ button.setButtonType(.momentaryPushIn)
+ button.bezelStyle = .rounded
+ return button
+ }()
+
+ init() {
+ super.init(nibName: nil, bundle: nil)
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ override func loadView() {
+ let view = NSView()
+
+ button.target = self
+ button.action = #selector(buttonClicked)
+
+ view.addSubview(button)
+ button.translatesAutoresizingMaskIntoConstraints = false
+ NSLayoutConstraint.activate([
+ button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
+ button.centerYAnchor.constraint(equalTo: view.centerYAnchor)
+ ])
+ self.view = view
+ }
+
+ func setButtonTitle(_ title: String) {
+ button.title = title
+ }
+
+ @objc func buttonClicked() {
+ onButtonClicked?()
+ }
+}