MonitorControl/MonitorControl/ButtonCellView.swift
Markus Reiter 6e91c71353 Various Enhancements (#66)
* Update to Swift 5.0 and run `swiftformat`.

* Refactor `MediaKeyTap` start/restart.

* Remove useless comments.

* Reorder files.

* Add German translation.

* Switch to Carthage.

* Use `DDC.swift`.

* Add `NSScreen` extension.

* Simplify menu layout.

* Hide the display’s built-in OSD.

* Fix launch at login helper.

* Fix `quitClicked` connection.

* Refactor build phases.

* Use `os_log` instead of `print`.

* Use more specific check for `minReplyDelay`.

* Add whitelist.
2019-05-07 15:01:26 +02:00

29 lines
699 B
Swift

import Cocoa
import os.log
class ButtonCellView: NSTableCellView {
@IBOutlet var button: NSButton!
var display: Display?
let prefs = UserDefaults.standard
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
}
@IBAction func buttonToggled(_ sender: NSButton) {
if let display = display {
switch sender.state {
case .on:
self.prefs.set(true, forKey: "\(display.identifier)-state")
case .off:
self.prefs.set(false, forKey: "\(display.identifier)-state")
default:
break
}
#if DEBUG
os_log("Toggle enabled display state: %@", type: .info, sender.state == .on ? "on" : "off")
#endif
}
}
}