选择后的osx NSPopUpButton通知

时间:2017-02-25 22:15:45

标签: swift macos notifications nspopupbutton

我需要在用户从NSPopUpButton更改项目后知道用户选择。

为什么NSPopUpButton控件在用户操作之前有通知。

  

当NSPopUpButton对象收到鼠标按下事件时发布 - 也就是说,当用户即将从菜单中选择一个项目时。

实施NSPopUpButton通知正常:

@objc func popUpButtonUsed(notification: NSNotification){
    print(distributionPopUpButton.titleOfSelectedItem!)
}

但是如何在用户选择后触发操作/方法?

谢谢!

1 个答案:

答案 0 :(得分:2)

就像以下一样。

@IBAction func popUpButtonUsed(_ sender: NSPopUpButton) {
    print(sender.indexOfSelectedItem)
}