|
@@ -13,28 +13,28 @@ import AppKit
|
|
|
@objc optional func componentDropdownToolDidShowPopupView(_ view: ComponentDropdownTool)
|
|
|
|
|
|
@objc optional func componentDropdownToolDidClicked(_ view: ComponentDropdownTool, menuItem: ComponentMenuitemProperty?)
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
-
|
|
|
+
|
|
|
@IBOutlet var contendBox: NSBox!
|
|
|
@IBOutlet var iconImage: NSImageView!
|
|
|
@IBOutlet var dropImage: NSImageView!
|
|
|
@IBOutlet var titleLabel: NSTextField!
|
|
|
-
|
|
|
+
|
|
|
@IBOutlet var imageLeftConst: NSLayoutConstraint!
|
|
|
@IBOutlet var labelLeftConst: NSLayoutConstraint!
|
|
|
|
|
|
private var _properties : ComponentDropdownToolProperty = ComponentDropdownToolProperty()
|
|
|
-
|
|
|
+
|
|
|
private var groupView: ComponentGroup!
|
|
|
-
|
|
|
+
|
|
|
weak open var delegate: ComponentDropdownToolDelegate?
|
|
|
-
|
|
|
+
|
|
|
public override func draw(_ dirtyRect: NSRect) {
|
|
|
super.draw(dirtyRect)
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// MARK: 初始化
|
|
@@ -61,7 +61,7 @@ public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
//MARK: - Setter and Getter
|
|
|
public var properties : ComponentDropdownToolProperty {
|
|
|
get {
|
|
|
- return _properties
|
|
|
+ return _properties
|
|
|
}
|
|
|
set {
|
|
|
_properties = newValue
|
|
@@ -73,7 +73,7 @@ public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
refreshUI()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//MARK: - SetupUI
|
|
|
func setupUI() {
|
|
@@ -133,6 +133,13 @@ public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
if properties.isDisabled == true {
|
|
|
fillColor = properties.propertyInfo.color_dis
|
|
|
textColor = properties.propertyInfo.textColor_dis
|
|
|
+ if let color = fillColor, let image = properties.leftIcon?.filled(with: color) {
|
|
|
+ iconImage.image = image
|
|
|
+ }
|
|
|
+ if let color = fillColor, let image = dropImage.image?.filled(with: color) {
|
|
|
+ dropImage.image = image
|
|
|
+ }
|
|
|
+ fillColor = NSColor.clear
|
|
|
}
|
|
|
|
|
|
if let color = fillColor {
|
|
@@ -142,7 +149,7 @@ public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
titleLabel.textColor = color
|
|
|
}
|
|
|
titleLabel.font = properties.propertyInfo.textFont
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//MARK: - Public Method
|
|
@@ -152,7 +159,7 @@ public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
refreshUI()
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//MARK: - MouseEvent
|
|
|
public override func mouseEntered(with event: NSEvent) {
|
|
|
super.mouseEntered(with: event)
|
|
@@ -170,11 +177,11 @@ public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
|
|
|
public override func mouseExited(with event: NSEvent) {
|
|
|
super.mouseExited(with: event)
|
|
|
-
|
|
|
+
|
|
|
if properties.state != .pressed {
|
|
|
properties.state = .normal
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
refreshUI()
|
|
|
}
|
|
|
|
|
@@ -194,13 +201,16 @@ public class ComponentDropdownTool: ComponentBaseXibView {
|
|
|
super.mouseUp(with: event)
|
|
|
|
|
|
guard let items = properties.menuItemArr else {
|
|
|
-
|
|
|
properties.state = .hover
|
|
|
refreshUI()
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if properties.isDisabled == true {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if groupView == nil {
|
|
|
groupView = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
|
|
|
}
|