title: Swift - detect is NSStatusItem hidden
body: <p>I'm working on MacOS menu bar app which can have variable length:</p>
  
  <pre><code>@IBOutlet weak var statusMenu: NSMenu!
  
  let statusItem: NSStatusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
  
  statusItem.title = "Long text..."
  statusItem.menu = statusMenu
  </code></pre>
  
  <p>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:</p>
  
  <ol>
  <li>check if statusItem is visible</li>
  <li>if no, check how much free space I have to adjust the shortening</li>
  <li>change the title</li>
  </ol>
  
  <p>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?</p>