-
-
Save kmalyshev/7ef834efaeed83014f6ba851582fca0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength) | |
let contentView = VStack { | |
Button("TestButton", action: { | |
print("testest") | |
}) | |
} | |
let view = NSHostingView(rootView: contentView) | |
view.frame = NSRect(x: 0, y: 0, width: 200, height: 200) | |
let menuItem = NSMenuItem() | |
menuItem.view = view | |
let menu = NSMenu() | |
menu.addItem(menuItem) | |
statusItem.menu = menu | |
statusItem.button?.title = "Test" |
Author
kmalyshev
commented
Jan 11, 2021
Hello.
thanks your answer here
And Do you know what control it is in the picture above ? It hovers with a translucent background and I am sure it is not a button.
Thanks.
Hello.
thanks your answer here And Do you know what control it is in the picture above ? It hovers with a translucent background and I am sure it is not a button. Thanks.
Hello @makhocheung,
You should try using Accessibility Inspector, it reveals what's being used under the hood.
Also please check this topic about regular NSMenuItems being highlighted in a custom way. https://stackoverflow.com/questions/6054331/highlighting-a-nsmenuitem-with-a-custom-view
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment