I'm working on MacOS menu bar app which can have variable length:
@IBOutlet weak var statusMenu: NSMenu!
let statusItem: NSStatusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
statusItem.title = "Long text..."
statusItem.menu = statusMenu
If the status item title length will be to long to display and the menu bar item will hide I'd like to change the title to the shortened version. So I need:
- check if statusItem is visible
- if no, check how much free space I have to adjust the shortening
- change the title
Point 3 is easy. I have problems with point 1 and 2. None of the stackoverflow answers work for me. Is there any way how this can be done?