0

I need to know the user selection after the user changed the item from a NSPopUpButton.

Why on earth does the NSPopUpButton control has a notification before the user action.:

Posted when an NSPopUpButton object receives a mouse-down event—that is, when the user is about to select an item from the menu.

Implementing the NSPopUpButton notification works fine:

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

But how can I trigger an action/method after the user selection?

Thanks!

JFS
  • 2,992
  • 3
  • 37
  • 48
  • Set an IBAction. Isn't it that simple? – El Tomato Feb 25 '17 at 22:27
  • 1
    not for me. how do I trigger an action after users selection? thanks. – JFS Feb 25 '17 at 22:33
  • ok, ok, that's simple. Using an action is indeed calling the method after the user selection. Perfect. Thanks. Wasn't that obvious for me. Create an answer that I can accept your help! – JFS Feb 25 '17 at 22:38

1 Answers1

2

It's like the following.

@IBAction func popUpButtonUsed(_ sender: NSPopUpButton) {
    print(sender.indexOfSelectedItem)
}
El Tomato
  • 6,479
  • 6
  • 46
  • 75