Created
June 23, 2023 08:22
-
-
Save brandonasuncion/70a6422fb13cab86c78c108cfb4cce3e to your computer and use it in GitHub Desktop.
easy NSMenu
This file contains hidden or 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
| func applicationDidFinishLaunching(_ aNotification: Notification) { | |
| let appName = ProcessInfo.processInfo.processName | |
| NSApp.mainMenu = NSMenu { | |
| NSMenuItem { | |
| NSMenuItem(title: "About \(appName)", action: #selector(NSApplication.orderFrontStandardAboutPanel(_:)), keyEquivalent: "") | |
| NSMenuItem.separator() | |
| NSMenuItem(title: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "w") | |
| } | |
| NSMenuItem(title: "View") { | |
| NSMenuItem(title: "Toggle Light/Dark mode", action: #selector(toggleLightDark), keyEquivalent: "t") | |
| NSMenuItem(title: "Copy as Image", action: #selector(screenshot), keyEquivalent: "c") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment