SliderVC.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // SliderVC.swift
  3. // KMComponentLibrary
  4. //
  5. // Created by Niehaoyu on 2024/8/29.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. class SliderVC: NSViewController {
  10. @IBOutlet weak var slider: ComponentSlider!
  11. @IBOutlet weak var sizeBox: NSComboBox!
  12. @IBOutlet weak var disableButton: NSButton!
  13. @IBOutlet weak var inputButton: NSButton!
  14. @IBOutlet weak var leftIconBtn: NSButton!
  15. @IBOutlet weak var rightIconBtn: NSButton!
  16. @IBOutlet weak var sliderWidthConst: NSLayoutConstraint!
  17. @IBOutlet weak var sliderHeightConst: NSLayoutConstraint!
  18. override func viewDidLoad() {
  19. super.viewDidLoad()
  20. // Do view setup here.
  21. self.reloadData()
  22. }
  23. func reloadData() {
  24. let isDisable = self.disableButton.state == .on
  25. var size: ComponentSize = .m
  26. if self.sizeBox.indexOfSelectedItem == 0 {
  27. size = .m
  28. } else if self.sizeBox.indexOfSelectedItem == 1 {
  29. size = .s
  30. }
  31. let showInput = self.inputButton.state == .on
  32. }
  33. @IBAction func buttonAction(_ sender: Any) {
  34. self.reloadData()
  35. }
  36. override func mouseDown(with event: NSEvent) {
  37. super.mouseDown(with: event)
  38. self.view.window?.makeFirstResponder(nil)
  39. }
  40. }