// // ASIntPropertyCell.swift // KdanAuto // // Created by 朱东勇 on 2023/4/17. // import Cocoa class ASIntPropertyCell: ASPropertyCell, NSTextFieldDelegate { @IBOutlet var m_titleLbl:NSTextField! @IBOutlet var m_valueLbl:NSTextField! override class func shared() -> ASPropertyCell? { var objects : NSArray! Bundle.main.loadNibNamed("ASIntPropertyCell", owner: nil, topLevelObjects: &objects) for tView in objects { if let tv = tView as? ASIntPropertyCell { return tv } } return nil } /// Setter override func setPropertyInfo(_ info:NSDictionary) { super.setPropertyInfo(info) self.m_titleLbl.stringValue = "\(info.value(forKey: "Name") ?? ""):" setValue((info.value(forKey: "DefaultValue") ?? "0") as AnyObject) } override func setValue(_ value:AnyObject) { super.setValue(value) if (value as? NSNumber) != nil { self.m_valueLbl.stringValue = "\((value as! NSNumber).intValue)" }else if ((value as? String) != nil) { self.m_valueLbl.stringValue = "\((value as! NSString).intValue)" } } override func value() -> AnyObject { return NSNumber(value: NSString(string: self.m_valueLbl.stringValue).intValue) } override func setEnabled(_ enabled:Bool) { super.setEnabled(enabled) self.alphaValue = enabled ? 1 : 0.6 self.m_valueLbl.isEnabled = enabled; } }