1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- //
- // KMUserFbDespItemView.swift
- // PDF Reader Pro Edition
- //
- // Created by tangchao on 2024/7/11.
- //
- import Cocoa
- class KMUserFbDespItemView: NSView, NibLoadable {
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var box: NSBox!
- @IBOutlet weak var scrollView: NSScrollView!
- @IBOutlet var textView: NSTextView!
- @IBOutlet weak var tipLabel: NSTextField!
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- let title = NSLocalizedString("Describe Question", comment: "")
- let attri = NSMutableAttributedString(string: title)
- attri.addAttribute(.font, value: NSFont.systemFont(ofSize: 13), range: NSMakeRange(0, title.count))
-
- attri.append(.init(string: "*", attributes: [NSAttributedString.Key.font : NSFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor : NSColor(red: 250/255.0, green: 31/255.0, blue: 93/255.0, alpha: 1.0)]))
-
- self.titleLabel.attributedStringValue = attri
-
- self.textView.textContainerInset = NSSize(width: 6, height: 6)
- self.textView.km_placeholderString = NSLocalizedString("Please tell us the details so that we can help you faster", comment: "")
- self.textView.delegate = self
-
- self.box.borderWidth = 0.5
- self.box.cornerRadius = 5
- self.box.borderColor = NSColor(white: 0, alpha: 0.08)
- // self.textView.font = [NSFont systemFontOfSize:12];
- // self.textView.textColor = [NSColor colorWithRed:81/255.f green:91/255.f blue:117/255.f alpha:1.f];
- self.textView.enclosingScrollView?.wantsLayer = true
- self.textView.enclosingScrollView?.borderType = .noBorder
- self.textView.enclosingScrollView?.layer?.cornerRadius = 5
- self.textView.enclosingScrollView?.layer?.masksToBounds = true
- self.textView.isRichText = false
- self.textView.backgroundColor = .clear
-
- self.tipLabel.stringValue = NSLocalizedString("Please fill in details", comment: "")
- self.tipLabel.textColor = NSColor.km_init(hex: "#FA1E5D")
- self.tipLabel.font = NSFont(name: "SFProText-Regular", size: 11)
- self.tipLabel.isHidden = true
- }
-
- func string() -> String {
- return self.textView.string
- }
-
- func showTip() {
- self.window?.makeFirstResponder(self.textView)
- self.box.horLightShakeAnimation()
-
- self.tipLabel.isHidden = false
- }
-
- func hiddenTip() {
- self.tipLabel.isHidden = true
- }
- }
- extension KMUserFbDespItemView: NSTextViewDelegate {
- func textViewDidChangeSelection(_ notification: Notification) {
- if self.textView.isEqual(to: notification.object) {
- self.hiddenTip()
-
- self.textView.placeholderLabel.isHidden = self.textView.string.count > 0
- }
- }
-
- // func textViewDidChangeTypingAttributes(_ notification: Notification) {
- //
- // }
-
- func textDidChange(_ notification: Notification) {
- if self.textView.isEqual(to: notification.object) {
- self.hiddenTip()
-
- self.textView.placeholderLabel.isHidden = self.textView.string.count > 0
- }
- }
- }
|