How to make popup button in SwiftUI for macOS

Issue #748

There is said to be PopUpButtonPickerStyle and MenuPickerStyle but these don’t seem to work.

There’s Menu button it shows a dropdown style. We fake it by fading this and overlay with a button. allowsHitTesting does not work, but disabled seems to do the trick

1
2
3
4
5
6
7
8
9
10
11
12
13
Menu {
Button("About", action: ActionService.onAbout)
Button("Quit", action: ActionService.onQuit)
} label: {
Text("")
}
.frame(width: 24)
.opacity(0.01)
.overlay(
makeButton(action: {}, "gearshape.fill")
.disabled(true)
.foregroundColor(Color.secondaryLabel)
)

Comments