MonitorControl/MonitorControl/Objects/ButtonCellView.swift
Guillaume Broder 85f4293199
🎉 v1.2
Many changes in commit…
- Contrast slider is back !
- Added a Preferences Window
- Function keys (should) work
- If (like me) your screen backlight is still too bright even at 0, you can now set the contrast to 0 when the brightness hit 0 too
- App can now be started at login (Needs to be tested)

Signed-off-by: Guillaume Broder <iamnotheoneyouseek@gmail.com>
2018-02-18 17:55:32 +01:00

34 lines
759 B
Swift

//
// ButtonCellView.swift
// MonitorControl
//
// Created by Guillaume BRODER on 07/01/2018.
// Copyright © 2018 Mathew Kurian. All rights reserved.
//
import Cocoa
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:
prefs.set(true, forKey: "\(display.identifier)-state")
case .off:
prefs.set(false, forKey: "\(display.identifier)-state")
default:
break
}
print("Toggle enabled display state -> \(sender.state == .on ? "on" : "off")")
}
}
}