I have the following code: (can be copy-pasted to New macOS project)
import Cocoa
import SwiftUI
@NSApplicationMain
class AppDelegate: NSObject, NSAppl
Here is possible approach. There might be more accurate calculations for menu position, including taking into account possible differences of userInterfaceLayoutDirection, but the idea remains the same - take possible events under manual control and make own decision about what to do on each event.
Important places commented in code. (Tested on Xcode 11.2, macOS 10.15)
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var statusBarItem: NSStatusItem!
func applicationDidFinishLaunching(_ aNotification: Notification) {
let statusBar = NSStatusBar.system
statusBarItem = statusBar.statusItem(
withLength: NSStatusItem.squareLength)
statusBarItem.button?.title = "