我需要在用户从NSPopUpButton
更改项目后知道用户选择。
为什么NSPopUpButton
控件在用户操作之前有通知。
当NSPopUpButton对象收到鼠标按下事件时发布 - 也就是说,当用户即将从菜单中选择一个项目时。
实施NSPopUpButton
通知正常:
@objc func popUpButtonUsed(notification: NSNotification){
print(distributionPopUpButton.titleOfSelectedItem!)
}
但是如何在用户选择后触发操作/方法?
谢谢!
答案 0 :(得分:2)
就像以下一样。
@IBAction func popUpButtonUsed(_ sender: NSPopUpButton) {
print(sender.indexOfSelectedItem)
}