eemmrrkk
eemmrrkk

Reputation: 1700

How to expand NSPopUpButton in Swift programmatically?

I am trying to expand NSPopUpButton with Swift. For a native OSX app, I have to override a design like a screenshot below.

enter image description here

My purpose is adding a button as with down_iconand when I click it the popup button must expand. I can't do it in NSPopUpButton but in this question thread, this is possible for NSComboBox. Question Here

As I tried in NSComboBox,

comboBoxCell.performSelector(Selector("popUp:"))

code block not worked for NSPopUpButton because of there is no selector for NSPopUpButton for popping up.

Also, try

phoneCodesPopup.setAccessibilityExpanded(true)

but it is not expanded.

How can I open NSPopUpButton programmatically?

Thanks in advance!

Upvotes: 0

Views: 599

Answers (1)

Sweeper
Sweeper

Reputation: 271420

Unlike NSComboBox, clicking on NSPopoverButton, anywhere, will make it pop up, so you just need performClick:

yourPopup.performClick(nil)

Upvotes: 1

Related Questions