5

I've trying to make a NSPopover automatically appear below an icon in the status bar, the first time the user installs my application. Like google drive does:

enter image description here

I'm using the exact code mentioned this answer which works perfectly for manually showing a popover (e.g. on a user click). To get the popover to display automatically I added the following line at the end of the applicationDidFinishLaunching method: [self.controller menuletClicked:1] which calls down into showRelativeToRect... Now this works perfectly sometimes (the popover appears right below the icon in the status bar), but other times the popover shows up at the bottom left of my screen. It works more consistently if I wait a few seconds and then execute that line of code (e.g. via dispatch_after...). But still occasionally fails and shows up the the bottom of my screen.

This indicates that something isn't 'ready'? (as suggested in this question) - but I've checked the popover object isn't nil, and the bounds of the rectangle look good. I've also added a loadView to try force a load, but nothing seems to work!

What is the correct way to get a NSPopover to automatically show up? Or how to ensure it will show up in the right place? thanks!!

Community
  • 1
  • 1
patrick
  • 380
  • 2
  • 14

0 Answers0