1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // ASIntPropertyCell.swift
- // KdanAuto
- //
- // Created by 朱东勇 on 2023/4/17.
- //
- import Cocoa
- class ASBOOLPropertyCell: ASPropertyCell {
- @IBOutlet var m_checkBtn:NSButton!
- override class func shared() -> ASPropertyCell? {
- var objects : NSArray!
-
- Bundle.main.loadNibNamed("ASBOOLPropertyCell", owner: nil, topLevelObjects: &objects)
-
- for tView in objects {
- if let tv = tView as? ASBOOLPropertyCell {
- return tv
- }
- }
-
- return nil
- }
-
-
- /// Setter
- override func setPropertyInfo(_ info:NSDictionary) {
- super.setPropertyInfo(info)
-
- self.m_checkBtn.title = "\(info.value(forKey: "Name") ?? ""):"
- setValue((info.value(forKey: "DefaultValue") ?? "0") as AnyObject)
- }
-
- override func setValue(_ value:AnyObject) {
- super.setValue(value)
-
- if (value as? NSNumber)?.boolValue == true {
- self.m_checkBtn.state = .on
- }else {
- self.m_checkBtn.state = .off
- }
- }
-
- override func value() -> AnyObject {
- if (m_checkBtn.state == .on) {
- return NSNumber(booleanLiteral: true)
- }
- return NSNumber(booleanLiteral: false)
- }
-
- override func setEnabled(_ enabled:Bool) {
- super.setEnabled(enabled)
-
- self.alphaValue = enabled ? 1 : 0.8
- self.m_checkBtn.isEnabled = enabled;
- }
-
-
- ///IBAction
- @IBAction func valueChanged(_ sender:NSButton) {
- m_valueChange(self.value(), self)
- }
- }
|